PHP String Functions

Sheng-Shan Chen
Mar 24, 2021
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head><body><?php//String Function$str = "hello world";echo strlen($str); // string lengthecho "<br>";echo str_word_count($str); // the count of word -> hello + world = 2echo "<br>";echo strrev($str); // string reverse -> hello world => dlrow ollehecho "<br>";echo strpos($str, "world"); // string position => 6echo "<br>";echo str_replace("world","leaf",$str); // leaf -> world => hello leaf?></body></html>

refer from https://www.w3schools.com/php/php_string.asp

--

--