How do I clear all strings before a specified character?
The string below, I want to clear the vid= and the previous characters, that is, only 198445623 is reserved. This is where only vid= is a fixed character.
http://ooioosy.wwowo9e.com/owuiwd/vid=198445623
My current approach is this, by calculating the location of the vid= to clear, there is no way to save system resources?
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623"
SUBSTR ($vid, (Stripos ($vid, ' vid= ') +4));
Share to:
------Solution--------------------
In fact, you're also very resource-saving.
Give it a try.
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
echo Explode (' vid= ', $vid) [1];
------Solution--------------------
References:
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
Str_replace (' http://ooioosy.wwowo9e.com/owuiwd/vid= ', ', $vid);
?>
I wanted to use regular, but it was a waste of resources.
LZ writes very clearly--"this one of them only vid= is a fixed character"
------Solution--------------------
$str = ' http://ooioosy.wwowo9e.com/owuiwd/vid=198445623 ';
$arr = explode (' = ', $str);
echo $arr [1];