Hooch Posted November 21, 2009 Report Share Posted November 21, 2009 Hello all.I stumbled upon a handy script today.LINKYHere is the code from that link <?php$username = 'username';$password = 'password';$url = 'domain.com';$year = date('Y'); /* replace with 4 digit year */ $url = "http://".$username.":".$password."@".$url.":2082/awstats.pl?month=01&year=".$year."&config=".$url."〈=en&framename=mainright&output=main"; $buffer = file_get_contents($url);$buffer = strip_tags($buffer,"<tr><td>"); $regex = "{<tr><td>[0-9A-Za-z\s]*</td><td>([0-9]*)</td><td>([0-9]*)</td><td>([0-9]*)</td><td>([0-9]*)</td><td>([0-9A-Z\.\s]*)</td></tr>\n}";preg_match_all($regex,$buffer,$matches);print_r($matches[1]);?> This works well, but prints out the results in one line like so... Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 3 [7] => 265 [8] => 198 [9] => 345 [10] => 201 [11] => 0 ) How would I go about printing each months results in a format more pleasing to the eyes?At least show me how to print each result out by itself...that would be great.Thank you for your time. Link to comment Share on other sites More sharing options...
chibineku Posted November 22, 2009 Report Share Posted November 22, 2009 instead of simply using print_r($matches[1]);, you could foreach through them and then format the results as desired, eg:foreach($matches[1] as $k => $v) {echo "$k: $v<br />";} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now