strstr and substr

Difference between strstr and substr
No. strstr substr
1 It will return substring from the first matching occurrence to the end of string. It will return part of the string from the given index to its length parameters.
2 e.g.
$str = ‘abc.com';
echo strstr($str,’c’);
output :: c.com  
e.g.
$rest = substr("abcdef", -1);    // returns "f"
$rest = substr("abcdef", -2);    // returns "ef"
$rest = substr("abcdef", -3, 1); // returns "d"

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>