php - Extract a Flickr photo ID from URL
932
I need to extract a piece of a URL in PHP. From the URLhttp://www.flickr.com/photos/[email protected]/7885410582
I need only the7885410582
part.
My code:
$string2 = 'http://www.flickr.com/photos/[email protected]/7885410582';
preg_match_all('~s/ (.*?) /~i',$string2,$matches, PREG_PATTERN_ORDER);
echo $matches[1][0] . '<br />';
Can anyone look at it and correct it for me? Thanks in advance.
Answer
Solution:
you can use
Answer
Solution:
try this regex:
will find all digits before string end
or:
will find all digits after
/
sign before string endAnswer
Solution:
If the identifier you want is always the last in the URL, don't bother with regular expressions and instead use simple string functions.
Answer
Solution:
Try this:
Description
Demo
http://regex101.com/r/aL2hL3
Sample code