PHP String Functions
A string is sequence of characters, where a character is the same as a byte,hence php support 256 character set.
Split function, split the string function Tutorial into an array using regular expression and return the array.
Explode function , it is used to split a string using another sting.
PHP strlen() function:
The strlen() function is used to return the length of a string in characters.
Let’s take a example to find the length of our string “Hello happy!”:
<?php
echo strlen(“Hello happy!”);?>
Output will be:
12
Note: The length of a string is used in loop or other php string functions, when it is important to know when the string ends i.e. in a loop, we would want to stop the loop after the last character in the string.
PHP strpos() function:
The strpos() function is used to search for a string or specified characters within a string.
If a match is found, it will return the character position of the first match. If there is no match is found, it will return FALSE.
Let’s take a example to find a string ” happy!”in our string:
<?php
;echo strlen(“Hello happy!”);
?>
Output will be:
6
Note: The position of a string “happy” in our string is 6 position.The reason that it is 6 position, and not 7 position, is that the first position in the string is 0 not 1.













