Hooch Posted November 21, 2009 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 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
Archived
This topic is now archived and is closed to further replies.