Php intercepts specified strings in URLs in batches

Source: Internet
Author: User
I don't know if this title is correct... I saw a problem just now. he gave a group of ku6 video link addresses as follows:

I don't know if this title is correct... I saw a problem just now. he gave a group of ku6 video link addresses as follows:

Http://v.ku6.com/film/show_129194/nybK9dviY29g-kxd.html

Http://v.ku6.com/film/show_129191/YDS5hChA0bx-2Hlf.html

Http://v.ku6.com/film/show_129230/n1ogpkzI-LFQRL5_.html

Http://v.ku6.com/film/show_129182/CfhEWrBK04l0JZIf.html

Http://v.ku6.com/film/show_129199/Y-RkCmjgSKW8dE8m.html

His requirement is to get a string like nybK9dviY29g-kxd, YDS5hChA0bx-2Hlf, n1ogpkzI-LFQRL5 _, CfhEWrBK04l0JZIf, and Y-RkCmjgSKW8dE8m.
When I was thinking about how to use regular expressions, I found that the answer to the following two replies is too good.
One of the methods is to use the substr () function to traverse and Intercept:

$ Array = array ('http://v.ku6.com/film/show_129194/nybk9dviy29g-kxd.html ',
'Http://v.ku6.com/film/show_129191/yds5hcha0bx-2hlf.html ',
'Http://v.ku6.com/film/show_129230/n1ogpkzi-lfqrl5_.html ',
'Http://v.ku6.com/film/show_129182/cfhewrbk04l0jzif.html ',
'Http://v.ku6.com/film/show_129199/y-rkcmjgskw8de8m.html ');
Foreach ($ array as $ value ){
Print substr ($ value,-21,-5 )."
";
}
?>

The other is the pathinfo () function:
Mixed pathinfo (string $ path [, int $ options])

'Http://v.ku6.com/film/show_129191/yds5hcha0bx-2hlf.html ',
'Http://v.ku6.com/film/show_129230/n1ogpkzi-lfqrl5_.html ',
'Http://v.ku6.com/film/show_129182/cfhewrbk04l0jzif.html ',
'Http://v.ku6.com/film/show_129199/y-rkcmjgskw8de8m.html ');
Foreach ($ url as $ arr ){
$ Arr = pathinfo ($ arr); print_r ($ arr );
};
?>

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.