PHP – Strings Functions
String functions are the most important functions frequently used in PHP. String is the sequence of characters, like “Let’s learn String functions”. There is no installation required to use string function.
$name = “Hirdesh Bhardwaj”;
String Concatenation Operator
To concatenate two string variables together, we use the dot (.) operator −
echo $txt1 . ” ” . $txt2;
Using the strlen() function
The strlen() function is used to get the length of a string.
This will produce the following result – 10 (including space)
Using the strpos() function
The strpos() function is used to search for a text or character within a string. If the value is found then this will return the position of the first value. If no match is found, it will return FALSE.
Let’s see if we can find the string “PHP” in our string −
echo strpos(“Hello PHP”,”PHP”);
This will produce the following result – 6
The explode() Function: Used to convert strings into an array variable. It can be used in case where the information that you want lies in a larger string, you can extract it out with the explode() function.
$db = explode(‘;’,”host=localhost;db=hirdesh;uid=root “);
Array (  => host=localhost  => db=hirdesh  => uid=root