How to clear all strings before a specified character

Source: Internet
Author: User
How to clear all strings before a specified character? 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?198445623how can I clear all strings before a specified character?
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];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.