wow, thanks jsim & thorpe. that works great. I was trying to get the array working but i kept croping up errors.
If you would be so kind as to look at the second part of my code and possilbly cut it down that would be last problem i promise!!
What the code does is goes to a URL views the source, then via trial and error i adjust each code to copy the html line with the price of the product in it. then the badword filter filters out everything apart from numbers and "." then the program pastes the remaining and hopfully price into the website.txt file for me to view on one page.
Basically i need a program that can grab the price from different URL's that i enter. Viewing the source code and copy & pasting the line then filtering is a working way but I guess my code and thinking is a bit lame.
I guess you guys will be lol when u see the code but a trimmed version will help me price compare quicker.
<?
function filterBadWords($str){
$badwords=array( "[a]", "", "[c]", "[d]" , "[e]", "[f]", "[g]", "[h]" , "", "[j]" ,"[k]", "[l]", "[m]", "[n]", "[o]", "[p]", "[q]", "[r]" , "", "[t]" , "", "[v]", "[w]", "[x]", "[y]", "[z]" , "[<]", "[>]" ,"[/]", "[]" , "[']" , "[%]", "[=]" , "[+]", "[{]", "[}]", "[!]", "[#]", "[&]" , "[*]", "[:]" , "[;]");
$replacements=array( "", "", "" );
for($i=0;$i < sizeof($badwords);$i++){
srand((double)microtime()*1000000);
$rand_key = (rand()%sizeof($replacements));
$str=eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
//Start program with the target URL
$lines = file('http://www.ellis-brigham.com/cgi-bin/psProdDet.cgi/204194||@cTents@bThe%20North%20Face|0|user|1,0,0,1|27|');
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
$html = implode($lines) ;
//Filter function call
$html = filterBadWords($html);
$file = 'website2.txt';
$fp = fopen( "website2.txt", "w");
if (is_readable($file)) {;
$inputString = ( $html );
fwrite( $fp, $inputString );
echo "<br>";
} else { echo "I have done nothing";
};
$filearray = file('website2.txt');
$fp = fopen( 'website2.txt' ,"w");
$c=count($filearray);
//Added lines to the top - high number mores lines add on to the top
for($i=($c < 155 ? 0 : $c-155);$i < $c;++$i) {
fputs($fp,$filearray[$i]);
}
fclose($fp);
$inp = file('website2.txt');
$out = fopen('website2.txt','w');
//lower the number the more content comes through
for ($i=0;$i<count($inp)-150;$i++)
fwrite($out,$inp[$i]);
fclose($out);
//redirect code here to goto the next url
?>