字符串如下,我想清除vid=及之前的字符,也就是只保留198445623。这其中只有vid=是固定的字符。
http://ooioosy.wwowo9e.com/owuiwd/vid=198445623我现在的方法是这样的,通过计算vid=的位置来清除,有没有更节省系统资源的方法?
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623"
substr($vid,(stripos($vid,'vid=')+4));
http://ooioosy.wwowo9e.com/owuiwd/vid=198445623我现在的方法是这样的,通过计算vid=的位置来清除,有没有更节省系统资源的方法?
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623"
substr($vid,(stripos($vid,'vid=')+4));
试试这个
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
echo explode('vid=', $vid)[1];
$vid = "http://ooioosy.wwowo9e.com/owuiwd/vid=198445623";
str_replace('http://ooioosy.wwowo9e.com/owuiwd/vid=','',$vid );
?>本来想用正则,不过正则浪费资源
$arr = explode('=',$str);
echo $arr[1];