> The other way is to compile your C code into a PHP extension, which
> will let you run your code directly within PHP, but it can be faster
> and consume less memory than PHP code would (depending on exactly what
> you're doing).
Ok. It is probably about time I posted the awlfully slow section of code for
people to look at and state their opinions-
(Prior to this part the code has recursively scanned a directory and created
an array with all the path / file names).
foreach ($files as $filename) {
// Determine MIME type: (This uses pear mime_type module)
$mt=MIME_Type::autoDetect("$filename");
// If suitable MIME type open, read and process: (ie: all text files)
if (substr($mt,0,4) == "text") {
// obtain filesize needed for fread():
$fs = filesize("$filename");
// open the file:
$thefile = fopen("$filename","rb");
// read the file:
$content = fread($thefile,$fs);
// extract the information: ($pattern is a previously defined PCRE regex)
preg_match_all($pattern,$content,$matches);
// add it to our array:
$results = array_merge($matches[0],$results);
// unset the temporary array:
unset($matches);
// close the file:
fclose($thefile);
// count valid file(s) scanned:
$pv = $pv + 1;
}; // end the MIME type statement
// count files(s) scanned:
$p1 = $p1 + 1;
$bar1->update($p1);
// count data scanned:
$fc = $fc + $fs;
}; // end loop:
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---