// Examples Of substr function
$string = "123456789"; // our main string
echo substr($string,0,3); // print : 123
// Above example shows starting from 0 (First) position to total 3 characters
echo substr($string,1,3); // print : 234
// Above example shows starting from 1(Second) position to total 3 characters
echo substr($string,-1); // print : 9
// It Will give last character of string
echo substr($string,-4); // print : 6789
// It Will give last 4 characters of string

0 comments:
Post a Comment