Large array implode problem / performance

From: Date: Fri, 27 Oct 2000 13:36:36 +0000
Subject: Large array implode problem / performance
Groups: php.general 
Request: Send a blank email to php-general+get-22327@lists.php.net to get a copy of this message
Have a performance problem that I would need some advice on. I have a large file with e-mail adresses (about 50k of them) and do something like: function checkemail(&$item) { //do some regexping and dupechecks on $item } // Get adresses into array: $adr_array=file("50k_email_adresses.txt"); // Check every adress: array_walk($adr_array,'checkemail'); // Get them all back into a string to present in a html-form: $str_ok=implode("\n",$adr_array); I've managed to get the execution time down for everything but the last thing, to implode the array back into a string. This part takes forever... I run on the latest 3.x release so there are a couple of answers I don't need; "Upgrade to 4.0" or "Buy a dual PIII 1 gig and kick all other users" ;-) Some timings on 20k items (can't do 50k - it times out): Read file into array: 0.3 seconds (is there a way to write an array to a file this fast - ie has file() got a counterpart?) Walk the array (and perform work on it): 29 seconds. Implode the array: 60 seconds. The first and second step increases relative to the number of items, but the third step is somewhat exponential. Add another few k's of items and it runs off to very long times. Thanks for your time, Michael

« previous php.general (#22327) next »