need help with using stristr
I need help return everything after "I can read." I understand that this will search the string and find whats in the array $check
but how do I make it check and then return all whats found after "I开发者_高级运维 can read"?
$string = "I can read. I can count. I can spell.";
$check = array("I can count.", "I can't count.");
$find = stristr($string, $check, true);
echo $find;
$find = 'I can read.';
$string = '[...]';
echo substr($string,stripos($string,$find)+strlen($find));
Here is what the docs say the second parameter (needle) of stistr
:
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
Then you have to define $check
as follow:
$check = "I can read";
you do not need the third parameter if you want to get the substring after $check
, documentation states:
If TRUE, stristr() returns the part of the haystack before the first occurrence of the needle.
That's why you have to call stristr
with only two arguments:
$find = stristr($string, $check);
精彩评论