PHP has built-in functions to work with text easily. strlen(), strtoupper(), str_replace(), and explode() help you measure, convert, search, and split strings. These save a lot of time when handling user input and text data.
String Functions
$s = " Hello, PHP World! ";
strlen($s); // length
strtoupper($s); // HELLO, PHP WORLD!
strtolower($s); // hello, php world!
trim($s); // remove whitespace
ltrim($s); rtrim($s); // left / right trim
str_replace("PHP","Python",$s); // replace
strpos($s, "PHP"); // find position (or false)
substr($s, 7, 3); // "PHP"
str_repeat("ha", 3); // "hahaha"
str_word_count($s); // word count
str_split($s, 3); // split into chunks
chunk_split($s, 3, "-"); // "Hel-lo,-PHP-..."
wordwrap($s, 15, "\n", true);// wrap long lines
nl2br("line1\nline2"); // add <br> tags
htmlspecialchars("<b>"); // escape HTML
strip_tags("<b>Bold</b>"); // remove HTML