The strlen() function
The strlen() function is used to return the length
of a string.Let's find the length of a string:
<?php
echo strlen("Hello world!"); ?> |
12
|
The strpos() function
The strpos() function is used to search for
character within a string.If a match is found, this function will return the position of the first match. If no match is found, it will return FALSE.
Let's see if we can find the string "world" in our string:
<?php
echo strpos("Hello world!","world"); ?> |
6
|
The position of the string "world" in our string is position 6. The reason that it is 6 (and not 7), is that the first position in the string is 0, and not 1.
No comments:
Post a Comment