I want to remove everything before #blitz in this string:
$twit = rt @danisan01: #blitz ipva em frente ao barra sul, no recreio.
here's what I'm trying but I get no results on the output:
$array_bols = array("#bols", "#blitz", "#blitz ipva", "#ipva", "#detran", "#blitz de ipva", "#detran ipva", "#blitz d ipva");
foreach($array_bols as $blitz)
{
$twit = substr(strstr($twit, $blitz), strlen($blitz), (-1) * strlen($twit));
}
help
You get no output, because you iterate over a list of search words. And your $twit variable will be emptied at some point, because strstr
returns nothing if it can't find the searched subject.
What you wanted to do is following:
$array_bols = array("#bols", "#blitz", "#blitz ipva", "#ipva", "#detran", "#blitz de ipva", "#detran ipva", "#blitz d ipva");
foreach($array_bols as $blitz)
{
if ($tmp = strstr($twit, $blitz)) {
$twit = substr($tmp, strlen($blitz));
}
}
The inner substr also removes the #blitz
as I assume that's what your code was for. Note how you can leave out the substr() length parameter in such cases.