Get itunes id from url

what is the best way to retrieve id from itunes app link?

let say i have these link:

http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8

http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026

i just want to get the id, 457603026 using php preg_match

Answers


Without preg_match:

$url = 'http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8';
echo end(explode('/id', parse_url($url, PHP_URL_PATH)));

or, if you prefer:

$url = 'http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8';
$id = explode('/id', parse_url($url, PHP_URL_PATH));
echo $id[1];

Need Your Help

How can I find out why my thread is being stopped in ASP.NET?

asp.net iis-7.5

Our logs are reporting ThreadAbortExceptions that are stopping our Quartz.NET jobs at seemingly random intervals. From what I understand, this wouldn't normally be caused by something the thread it...

iPhone SDK: UIButton with both image and text possible?

ios iphone xcode uibutton

I have a button of size width 200 and height 270. I want to have text and image on the same button. Not as a background image on that text. Instead of this, I want to display the text with height 1...

Good Source Of .Net Design Patterns

.net design-patterns resources

I'm looking for a good online resource of software patterns. Preferably something with a comprehensive selection and concise well written explanations, not just a collection of links. .Net examples...