how can I use php to get exactly the id from google play url.
Google Play Url: https://play.google.com/store/apps/details?id=com.zing.zalo&hl=en
I want to get the com.zing.zalo . Thank you!
preg_matchor get the id from the url using
$_GET['id'], if you get this from url as other answer did.
$Url = "https://play.google.com/store/apps/details?id=com.zing.zalo&hl=en"; preg_match("/[^?]+(?:\?id=([^&]+).*)?/", "$Url", $matches); echo $matches; //com.zing.zalo
Working Example here Check online
The Longest way:
Simply you can use some PHP function to get it. Lets you have the following url.
$Url = "https://play.google.com/store/apps/details?id=com.zing.zalo&hl=en";
so what you need to explode the url using
? which is only one on the url.
$arr = explode("?", $Url);
From that array you need to store only the second part cause you need query string. So take only
$arr. Now explode again the
$arr with the
& sign which is divide the rest of the url i mean
$arr2 = explode("&", $arr);
Now you are all set, use another
explode function to get the com.zing.zalo from the
$idval = explode("=", $arr2);
Result, Just echo the second part of the
echo $idval; //com.zing.zalo