Provides utilities to work with texts
Converts strings to camelize style
echo Phalcon\Text::camelize("coco_bongo"); // CocoBongo echo Phalcon\Text::camelize("co_co-bon_go", "-"); // Co_coBon_go echo Phalcon\Text::camelize("co_co-bon_go", "_-"); // CoCoBonGo
Uncamelize strings which are camelized
echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo
Adds a number to a string or increment that number if it already is defined
echo Phalcon\Text::increment("a"); // "a_1" echo Phalcon\Text::increment("a_1"); // "a_2"
Generates a random string based on the given type. Type is one of the RANDOM_* constants
// "aloiwkqz" echo Phalcon\Text::random( Phalcon\Text::RANDOM_ALNUM );
Check if a string starts with a given string
echo Phalcon\Text::startsWith("Hello", "He"); // true echo Phalcon\Text::startsWith("Hello", "he", false); // false echo Phalcon\Text::startsWith("Hello", "he"); // true
Check if a string ends with a given string
echo Phalcon\Text::endsWith("Hello", "llo"); // true echo Phalcon\Text::endsWith("Hello", "LLO", false); // false echo Phalcon\Text::endsWith("Hello", "LLO"); // true
Lowercases a string, this function makes use of the mbstring extension if available
echo Phalcon\Text::lower("HELLO"); // hello
Uppercases a string, this function makes use of the mbstring extension if available
echo Phalcon\Text::upper("hello"); // HELLO
Reduces multiple slashes in a string to single slashes
echo Phalcon\Text::reduceSlashes("foo//bar/baz"); // foo/bar/baz echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); // http://foo.bar/baz/buz
Concatenates strings using the separator only once without duplication in places concatenation
$str = Phalcon\Text::concat( "/", "/tmp/", "/folder_1/", "/folder_2", "folder_3/" ); // /tmp/folder_1/folder_2/folder_3/ echo $str;
Generates random text in accordance with the template
// Hi my name is a Bob echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); // Hi my name is a Jon echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); // Hello my name is a Bob echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); // Hello my name is a Zyxep echo Phalcon\Text::dynamic("[Hi/Hello], my name is a [Zyxep/Mark]!", "[", "]", "/");
Makes a phrase underscored instead of spaced
echo Phalcon\Text::underscore("look behind"); // "look_behind" echo Phalcon\Text::underscore("Awesome Phalcon"); // "Awesome_Phalcon"
Makes an underscored or dashed phrase human-readable
echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" echo Phalcon\Text::humanize("five_cats"); // "five cats"
© 2011–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Text.html