开发者

Help with stripos() and substr()

开发者 https://www.devze.com 2023-03-02 20:48 出处:网络
how do I remove everything before \"sentido\" in this string: $string = \"#BLitz da #PM na est do pontal sentido prainha perto do camping\";

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

精彩评论

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