majoreasy/stringhelper

可以使用简单的字符串方法

v1.7.0 2019-02-22 07:26 UTC

This package is auto-updated.

Last update: 2024-09-22 20:09:25 UTC


README

你可以使用简单的字符串方法

安装

composer require majoreasy/stringhelper

使用方法

require_once('vendor/autoload.php'); use \Major\Helper\StrHelper;

  • toJadenCase

echo StrHelper::setStr("hi i like tea")::toJadenCase();
// Hi I Like Tea

  • 重复

echo StrHelper::setStr("Hello my name is James")::repeat(3);
// 结果:Hello my name is James Hello my name is James Hello my name is James

  • 切片

echo StrHelper::setStr("Im from England")::slice(0, 3);
// 结果:Im

  • 长度

echo StrHelper::setStr("I have brother")::length();
// 结果:14

  • toUpperCase

echo StrHelper::setStr("This is my message")::toUpperCase();
// 结果:THIS IS MY MESSAGE

  • toLowerCase

echo StrHelper::setStr("and I have Smart Phone")::toLowerCase();
// 结果:and i have smart phone

  • toASCII
    echo StrHelper::setStr("H")::toASCII();

  • // 结果:72

替换
echo StrHelper::setStr("Hi my name is murat")::replace("murat", "james");

  • // 结果:Hi my name is james

includes
echo StrHelper::setStr("Hi im living italy")::includes("italy");

  • // 结果:1

endsWith
echo StrHelper::setStr("Hi im living italy")::includes("italy");

  • echo StrHelper::setStr("Hi im living sweden")::endsWith("sweden");

startsWith
echo StrHelper::setStr("Hi im living italy")::includes("italy");