Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (strpos($url, "play.google.com/store") !== false) {
- // what to find in the string, in order to extract what we want
- $findthis = "?id=";
- // check where in the link "?id=" appears. we need the name of the app package.
- // to find the position of the start of the last occurence of a string, the idea is to reverse both $needle and $haystack, use strpos to
- // find the first occurence of $needle in $haystack, then count backwards by the length of $needle. finally, subtract $pos from length of $haystack.
- $packagepos = strlen($url) - (strpos(strrev($url), strrev($findthis)) + strlen($findthis));
- $packagename = substr($url,$packagepos+4); // extract the part of the link after "?id=" to the end of the string, that's the package name
- // check where/if the ampersand is that the web Market sometimes adds, so we can clean up the URL
- $ampersandpos = strpos($packagename, "&");
- // if the ampersand's position isn't bigger than 0, it doesn't exist, so ignore it
- if ($ampersandpos >0) {
- // extract the package name
- $packagename = substr($packagename, 0, $ampersandpos);
- // create a new Web Market URL, without the redundant info after the ampersand
- $url = substr($url, 0, strpos($url, "&"));
- }
- // create the Android Market search string for the QR code
- $qrURL = "market://search?q=pname:".$packagename;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement