We're not doing it 1000 times, or 100 times.. we're doing it one time. And when it comes down to it, my way (one time) if faster then your way.
http://projects.dopaul.com/test.php?...ce&hotel=co.uk
PHP Code:
<?php
$hotel = $_GET["hotel"]; // abbrev.. co.uk, com, ca.
$data = @file_get_contents("http://www.habbo.{$hotel}");
if(!$data) {
exit("Could not grab data.");
}
require_once 'Benchmark/Timer.php';
//create an instance of the Benchmark_Timer class
$timer = new Benchmark_Timer();
//Set "Start" marker
$timer->start();
$pattern = '<span class="stats-fig">';
$pattern .= '(\\d+)';
$pattern .= '(<\\/span>)';
preg_match_all ("/{$pattern}/is", $data, $matches);
$timer->setMarker('caleb');
preg_match('#<span class="stats-fig">(\d+)</span>#i', $data, $matches);
$timer->setMarker('iszak');
//Set "Stop" marker
$timer->stop();
//Returns formatted informations
$timer->display(true);
?>
<br />
<br />
<strong>caleb benchmark code:</strong>
<br />
<code>
$pattern = '<span class="stats-fig">';<br />
$pattern .= '(\\d+)';<br />
$pattern .= '(<\\/span>)';<br />
<br />
preg_match_all ("/{$pattern}/is", $data, $matches);
</code>
<br />
<br />
<strong>iszak benchmark code:</strong><br />
<code>
preg_match('#<span class="stats-fig">(\d+)</span>#i', $data, $matches);
</code>
When it comes to doing it once, my way is faster.