February 2013
Intermediate to advanced
538 pages
20h 55m
English
The strlen() function
returns the number of characters in a string:
$string='Hello, world';$length=strlen($string);// $length is 12
You can use the string offset syntax on a string to address individual characters:
$string='Hello';for($i=0;$i<strlen($string);$i++){printf("The %dth character is %s\n",$i,$string{$i});}The0thcharacterisHThe1thcharacteriseThe2thcharacterislThe3thcharacterislThe4thcharacteriso
Read now
Unlock full access