Re: Bug #13598 Updated: Arrays taking up to much memory

From: Date: Tue, 09 Oct 2001 11:52:29 +0000
Subject: Re: Bug #13598 Updated: Arrays taking up to much memory
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-67599@lists.php.net to get a copy of this message
> Okay... Jeroen thx for the time. > Just telling that PHP can't handle (multidimensional) arrays would have > been enough though. Then you didn't have to make suggestions that > aren't correct, like that I want to store 3/4 of a million single > bytes. Ever heard about empty records ? :) Also... when processing a > tab separated file into an array, the tabs aren't stored!! And I guess > the smarter approach is meant to be a "smarter approach for PHP". > Processing the file in memory is smart enough. It's a lot faster then > processing it while reading and writing from/to disk. The records are a > lot easier to address too. So I have to use a _different_ approach, not > a smarter approach. But ofcourse, when PHP needs about 20M to much > memory for a (small) file like this I'll have to process it one record > after the other. Btw: This bug isn't bogus... it's closed. PHP still > uses 20M to much memory, so it's not all that bogus ;) > > But anyway... Thx for the time you've put into it, telling me PHP can't > handle the (multidim) arrays. I think you are being a bit harsh, I don't know of many environments that would be able to handle what you want to do the way to insist on doing it. Dynamic multidimentional arrays are a tricky thing to implement. PHP is an awesome language, but it is not all things to all people. If you know your width, then two dimentional arrays can be done as: $val = $array_obj[($width * $Y) + $x] So to fill you array, do somthing like this: for($y=0; 1; $y++) { $csvret = fgetcsv(...) if(!$csvret) break; for($i=0; $i < $width; $i++) { $array_obj[($width *$y) + $i] = $csvret[$i]; } } Or something like that.

« previous php.dev (#67599) next »