Like this code?
Show the author your appreciation.
This function returns the overall ranking (in the US AppStore) for any iPhone App.
<?php
/*
$id = 9 digit number
You can find the App ID on the URL to the AppStore, for example awesomefactsapp.com link is the following:
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=309526865&mt=8
So in this case, the $id would be 309526865.
*/
function AppStore ( $id )
{
$result = file_get_contents ( 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=25204&popId=30' , false , stream_context_create ( json_decode ( '{"http":{"method":"GET","header":"X-Apple-Store-Front: 143441-1","user_agent":"iTunes\/4.2 (Macintosh; U; PPC Mac OS X 10.2)"}}' , true )));
if ( preg_match_all ( '~>(\d+)\.<.*?viewSoftware\?id=(\d+)&.*?draggingName="(.*?)"~s' , $result , $matches ) > 0 )
{
$result = array_search ( $id , $matches [ 2 ]);
if ( $result !== false )
{
$result ++;
echo '<h2>"' . $matches [ 3 ][ $result - 1 ] . '" is ranked #' . $result . ' overall in the US.</h2>' ;
}
return $result ;
}
return false ;
}
?>
Usage example:
<?php
var_dump ( AppStore ( 309526865 ))); // returns the rank or false if the App is not in the Top 100.
?>
grab the result of any calculation you submit to the Google Calculator. Categories : PHP , Arrays , Web Services , Regexps , Math. How to build a search query for any N number of words in a search string Categories : PHP , Regexps , Search Engines , Search file class , uploade file , download file already uploaded on another website Categories : PHP , PHP Classes , Filesystem , Web Services cPanel Email Accounts Creator Categories : PHP , PHP Classes , Email , Form Processing , Web Services Massreplace Categories : Filesystem , Regexps , Strings , PHP PHP Youtube Downloader - This is a set of PHP functions that can be used to download movies from Youtube.com.
Categories : PHP , CURL , Regexps validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email , Regexps , PHP Newbie Notes #7 - Ridiculous regex Categories : PHP , Beginner Guides , Regexps email validator check checker email e-mail email address Categories : PHP , Email , Regexps String Replacement and speed consideration
Categories : PHP , Strings , Regexps FormChecker Package - validate any data via classes and patterns.
Categories : PHP , Form Processing , PHP Classes , Regexps How to strip non-alpha characters from a string Categories : Regexps , PHP Tag content retrieval from websites with preg_match Categories : PHP , Regexps , Arrays , HTML and PHP PHP Script to find url links in a page Categories : PHP , URLs , Regexps , Arrays Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP Categories : PHP , HTTP , Regexps