Re: [php-337] timeout problem

From: Jason S.
Sent on: Monday, July 20, 2009 4:14 PM
Hey Frank,

How many iterations of filef lines does it go through before timing out?

With the nested loops, it looks like a max of 10 million or so iterations (3900 * 2900) which should be doable.


On Mon, Jul 20, 2009 at 3:56 PM, Frank_in_NY <[address removed]> wrote:
I have this simple code that seems to time out. It reads in two?external files(3900 lines & 2900 lines of text ) into two arrays and compares one file to the other to see how many matches there are. For some reason it only works when I use the?test files (10 lines of text). Can someone tell me why its not working?
PS:?I recently added the memory statement ,but it still doesnt work.
$filef = 'f.txt';
$filev = 'v.txt';
ini_set ( "memory_limit", "20M");
// check to make sure that file exists
//if (!file_exists($file1) {
//?die("Cannot find file!");
// read the whole file into a string
$file_f = join('', file($filef));
echo "filesf was read in"."<br>";
$file_v = join('', file($filev));
echo "filev was read in"."<br>";
// split our long string
$recordsf = preg_split ("/(\r?\n)/", $file_f);
$recordsv = preg_split ("/(\r?\n)/", $file_v);
echo "preg split done"."<br>";
foreach ($recordsf as $rf) {
?$rf = trim($rf);
?if ($rf != '') {
???????? foreach ($recordsv as $rv) {
???? ??? $rv = trim($rv);
???????? if ($rv != '') {
?????? If ($rf===$rv)
??????????????? echo "we have a match- Faculty".$rf." - Video faculty".$rv."<br>";
???? else
?????? echo "no match for ".$rv."<br>";
?????????? }
??? }

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Frank_in_NY ([address removed]) from The New York PHP Meetup Group.
To learn more about Frank_in_NY, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy