I’m using this code to get an int value from 3 different servers:
$js = file_get_contents( 'http://www.gta4.it/stat/view_stats.js.php?mode=3');
$value = trim( str_replace( array( "document.write('", "');"), '', $js));
$js = file_get_contents( 'http://www.tuttoirc.it/stats/view_stats.js.php?mode=3');
$value2 = trim( str_replace( array( "document.write('", "');"), '', $js));
$js = file_get_contents( 'http://www.thesims3.it/stat/view_stats.js.php?mode=3');
$value3 = trim( str_replace( array( "document.write('", "');"), '', $js));
$total =(string) ($value + $value2 + $value3);
$totalFormatted = number_format($total, 0, ',', ' ');
echo $totalFormatted;
and I output the sum value of all the counters.
Is there a way to auto update the counter without refreshing the page with ajax in a fancy way? Like an “electricity counter” or some visual effect every tot seconds?
You can use jquery to make requests back to your php code at regular intervals, like so: