从 iTunes 应用程序链接检索 ID 的最佳方法是什么?
假设我有这些链接:
http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8
http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026
我只想使用 php preg_match 获取 id,457603026
最佳答案
没有 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)));
或者,如果您愿意:
$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];
关于php - 从 url 获取 itunes id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8351655/