Hi guys,
After all your help a few months ago ive been off on my own in the big bad php world, but now im stumpped again, so a little help please?
Heres the deal:
there are people adding updates to orders which includes (the updated notes and their name) get wrote in to php file called $orderid.php (ie: 54125.php) . I need a little script to run through all the files from 1.php to 10000.php to seach for their name then recall the times its found the name. but obv a user can have updated the same file 1-10 times thus having what i wanna call 1-10 posts rather than 1 post. Still with me?
then run through the rest of the users and echo back "Gary has the most posts with $post 's" ; or whatever the result is etc...
Heres what ive got and it works but its crazy long, and my php is still only very basic.
$i = 1000;
while ($i <= 2000):
// get contents of the .php files
@$myText = file_get_contents( $i . ".php" );
// search the files for the users name ie "Roo"
$rooscount = substr_count($myText, 'Roo');
//if = or more than 1 store the info in a file
if ($rooscount >= 1 ){
$file = 'rooscount'.$i.'.php';
$fp = fopen( 'rooscount'.$i.'.php', "w");
fwrite( $fp, $rooscount );
};
$i++;
endwhile;
// blank the 'rooscountfinal.php' file for next use
$fp = fopen( 'rooscountfinal.php', "w");
fwrite( $fp, "" );
$i = 1000;
while ($i <= 2000):
//get the count contencts
@$myText = file_get_contents( "rooscount" . $i . ".php" );
$one = substr_count($myText, '1');
$two = substr_count($myText, '2');
$two = $two * 2;
$three = substr_count($myText, '3');
$three = $three * 3;
$four = substr_count($myText, '4');
$four = $four * 4;
$five = substr_count($myText, '5');
$five = $five * 5;
$six = substr_count($myText, '6');
$six = $six * 6;
$rooscount = $one + $two + $three + $four + $five + $six;
$a = file_get_contents ( 'rooscountfinal.php');
$rooscount = $rooscount + $a;
//make the final post count and write to file
if ($rooscount >= 1 ){
$fp = fopen( 'rooscountfinal.php', "w");
fwrite( $fp, $rooscount );
};
$i++;
endwhile;
any ideas on how i can slim it down ie: speed it up?
Thanks guys