开发者

Help with stripos() and substr()

how do I remove everything before "sentido" in this string:

$string = "#BLitz da #PM na est do pontal sentido prainha perto do camping";

i want the new string to be:

$string = "prainha perto do ca开发者_运维问答mping";

I keep failing when I try to do it with stripos and substr, help !


You can accomplish it without handing any string positions:

$string = strstr(strstr($string, "sentido"), " ");

This will first search for your word, and return the remainder of the string. The second strstr searches for the space afterwards, and returns the rest from there.


That's another easy way...

$string = "#BLitz da #PM na est do pontal sentido prainha perto do camping";

$s = explode('sentido', $string, 2);
$result = isset($s[1]) ? trim($s[1]) : "";
echo $result;

Output

sentido prainha perto do camping

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜