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

Color function to return a shade lighter and a shade darker

java android android-layout colors

Say I give the function a simple blue. Then it should return the hex code or RGB for dark blue, and for light blue. I am working in Java/android

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.