compare iterated values
Posted: Sun Oct 09, 2005 3:47 pm
How do i compare the value of a pervious iteration with the value of the current iteration?
which parses an id number. However after so many iterations (unknown) the id number before and after the iteration will be the same. I assume i have to create an 'if statement' which will compare the new id with the old id and when they are equal break the loop. So how do I store a previous value and compare it with the current value if after every iteration it replaces the old value is replaced with the new one?
Code: Select all
<?php
function <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://nw4.novaworld.net/NWStats.dll');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies');
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function getbannedcookie() {
for ($i = 0; $i < 100000; $i+=40){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://nw4.novaworld.net/NWStats.dll?success=bhd_6_name.htm&failure=bhd_6_main.htm&relay=bhd_6_relay.htm&msgbase=bhd_6_msg.htm&nodb=bhd_6_nodb.htm&statpage=bhd_6_stat.htm&pfid=26&statslot=0&action=charlist&top=' . $i . '&pattern=A');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
}
}
function parseit($file) {
global $matches;
preg_match('/<TD Align="left" Width=150><A HREF="NWStats.dll\?success=bhd_6_stat.htm\&failure=bhd_6_main.htm\&relay=bhd_6_relay.htm\&msgbase=bhd_6_msg.htm\&nodb=bhd_6_nodb.htm\&statpage=bhd_6_stat.htm\&pfid=26\&statslot=0\&action=stats\&showchid=(.*?)">(.*?)<\/A><\/TD>/', $file, $matches);
}
getbannedcookie();
parseit(<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>());
echo $matches[1];
?>