Re: Size of Arrays

From: Date: Fri, 30 Jan 2004 20:34:52 +0000
Subject: Re: Size of Arrays
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-176396@lists.php.net to get a copy of this message
Should anyone be planning experiments or projects with large arrays, use a for() loop instead of a foreach() loop when working with your array. And be sure to count the array, stick that result into a variable, then compare against the variable instead of running the count() again. On huge arrays (hundreds of thousands of elements, three dimensions, several megabytes) the performance impact is huge! The downside is you'll probably have to use numeric keys instead of associative, but for big arrays, numeric keys will probably also keep more memory free and improve performance a bit. Good luck with your arrays! -Galen

« previous php.general (#176396) next »