The
substr() string function in PHP will return a part of a string according to the parameters you feed it. It can take up to three parameters. The first parameter is the string. The second parameter is the starting position in the string(can be a negative number to count from the end of the string if you like). The third parameter is the length of how many characters in the string that you wish to select and make a substring out of.
<?php
$myString = "Welcome to the circus";
$result1 = substr($myString, 1);
$result2 = substr($myString, 8);
$result3 = substr($myString, 0, 8);
$result4 = substr($myString, -7);
$result5 = substr($myString, -7, 4);
echo $result1."<br />";
echo $result2."<br />";
echo $result3."<br />";
echo $result4."<br />";
echo $result5."<br />";
?>
elcome to the circus
to the circus
Welcome
circus
cir