-
Notifications
You must be signed in to change notification settings - Fork 165
Strings
Dmitriy Zayceff edited this page Oct 15, 2015
·
8 revisions
The all string functions and methods support Unicode like in Java.
The JPHP has own util class for working with strings php\lib\String, for example:
WARNING
If JPHP cannot find
php\lib\Stringclass, you are using the new version of JPHP where this class has been renamed tophp\lib\Str.
use php\lib\String;
$result = String::sub($string, 1);
// instead of ...
$result = substr($string, 1);This class contains many useful methods:
-
strpos->String::pos -
stripos->String::posIgnoreCase -
strrpos->String::lastPos -
strripos->String::lastPosIgnoreCase -
strcmp->String::compare -
strcasecmp->String::compareIgnoreCase,String::equalsIgnoreCase -
???->String::startsWith -
???->String::endsWith -
strtolower->String::lower -
strtoupper->String::upper -
strlen->String::length -
str_replace->String:replace// unable to work with arrays -
str_repeat->String::repeat -
trim->String::trim -
rtrim->String::trimRight -
ltrim->String::trimLeft -
strrev->String::reverse -
str_shuffle->String::shuffle,String::random -
explode->String::split -
implode->String::join -
iconv->String::encode,String::decode -
ctype_lower->String::isLower -
ctype_upper->String::isUpper -
substr_count->String::count -
sprintf->String::format -
ucfirst->String::upperFirst -
lcfirst->String::lowerFirst
JPHP Group 2015