Re: re-keying an array

From: Date: Fri, 30 Apr 2004 07:55:14 +0000
Subject: Re: re-keying an array
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-185017@lists.php.net to get a copy of this message
* Thus wrote Mattias Thorslund (mattias@inreach.com): > Just a quick follow-up question on that: > > Curt Zirzow wrote: > > >foreach(array_slice($filenames, 0, 2) as $filename) { > > $files[] = "path/to/" . $filelname; > >} > > > > > > Will a function (such as the array_slice here) in a foreach statement > get re-evaluated for each iteration, or is it evaluated just once? Only once. > > In other words, is there anyhing gained by doing: > > $short_array = array_slice($filenames, 0, 2); > > foreach($short_array as $filename) { > $files[] = "path/to/" . $filelname; > } Nothing really except mabey that it might be a little readable. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#185017) next »