Extracting a Substring Using substr
The substr() function returns a part of a string. You provide a string and the position of the first character to be extracted (keep in mind that the first character has the index 0). From this character on, the rest of the string is returned. If you only want to return a part of it, provide the length in the third parameter. The preceding code shows substr() in action and extracts Prep from PHP: Hypertext Preprocessor.
<?php $php = "PHP: Hypertext Preprocessor"; echo substr($php, 15, 4); //returns "Prep" ?>