0

How to use strlen?

22nd Aug 2016, 4:16 AM
michael carael
michael carael - avatar
3 Antworten
0
strlen() returns the number of bytes rather than the number of characters in a string. Example <?php $str = 'abcdef'; echo strlen($str); // 6 $str = ' ab cd '; echo strlen($str); // 7 ?>
22nd Aug 2016, 4:21 AM
Kon I am
Kon I am - avatar
0
how does it differ in strpos?
22nd Aug 2016, 4:29 AM
michael carael
michael carael - avatar
0
Find the position of the first occurrence of a substring in a string Example <?php $mystring = 'abc'; $findme = 'a'; $pos = strpos($mystring, $findme); // Note our use of ===. Simply == would not work as expected // because the position of 'a' was the 0th (first) character. if ($pos === false) { echo "The string '$findme' was not found in the string '$mystring'"; } else { echo "The string '$findme' was found in the string '$mystring'"; echo " and exists at position $pos"; } ?> Sorry for late reply.
22nd Aug 2016, 4:52 PM
Kon I am
Kon I am - avatar