How to clear all strings before a specified character? The string is as follows. how can I clear all strings before a specified character in vhttp?
The string is as follows. I want to clear vid = and the previous characters, that is, only 198445623 is retained. Only vid = is a fixed character.
Http://ooioosy.wwowo9e.com/owuiwd/vid=198445623
My current method is as follows. Is there a way to save system resources by calculating the location of vid =?
$ Vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623"
Substr ($ vid, (stripos ($ vid, 'vid = ') + 4 ));
Share:
------ Solution --------------------
In fact, you have saved a lot of resources.
Try this
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
echo explode('vid=', $vid)[1];
------ Solution --------------------
Reference:
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
str_replace('http://ooioosy.wwowo9e.com/owuiwd/vid=','',$vid );
?>
I wanted to use regular expressions, but regular expressions are a waste of resources.
LZ writes clearly -- "only vid = is a fixed character"
------ Solution --------------------
$str = 'http://ooioosy.wwowo9e.com/owuiwd/vid=198445623';
$arr = explode('=',$str);
echo $arr[1];