Justin Patrin wrote:
Richard Harb wrote:
Uh, I was wrong...
Foreach evaluates only once at initialisation... You can even unset
the array once into the loop and it still works perfectly well (not
that I recommend this as good practice or whatever, just did some
checking to be sure :)
Richard
That
Richard Harb wrote:
Uh, I was wrong...
Foreach evaluates only once at initialisation... You can even unset
the array once into the loop and it still works perfectly well (not
that I recommend this as good practice or whatever, just did some
checking to be sure :)
Richard
That will work because for
Uh, I was wrong...
Foreach evaluates only once at initialisation... You can even unset
the array once into the loop and it still works perfectly well (not
that I recommend this as good practice or whatever, just did some
checking to be sure :)
Richard
Friday, April 30, 2004, 9:55:14 AM, thus wa
* Thus wrote Mattias Thorslund ([EMAIL PROTECTED]):
> 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 s
Yes and no (in this case).
Yes, it'll be evaluated in each iteration and no, I don't think you'd
gain that much in this case because the evaluation would only take
place twice. Though I don't know how expensive array_slice vs.
creation of another variable and assigning a value to it is
But i
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?
In
On 30/04/2004, at 1:47 PM, Curt Zirzow wrote:
foreach(array_slice($filenames, 0, 2) as $filename) {
$files[] = "path/to/" . $filelname;
}
Ahh array_slice() is EXACTLY what I was looking for :)
---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubs
* Thus wrote John W. Holmes ([EMAIL PROTECTED]):
> Justin French wrote:
> >On 30/04/2004, at 12:06 PM, John W. Holmes wrote:
> >
> >
> >Like I said, always happy to see something in a few less lines :)
>
> If I'm following what you want to do correctly:
>
> for($i=0;$i<2;$i++)
> {
> $key = arra
* Thus wrote Justin French ([EMAIL PROTECTED]):
> On 30/04/2004, at 12:06 PM, John W. Holmes wrote:
>
> >Although this begs the question of why you'd need to "rekey" an
> >array...
>
> It seemed the easiest way to get the first two elements off the
> beginning of the array after shuffle()ing it
Justin French wrote:
On 30/04/2004, at 12:06 PM, John W. Holmes wrote:
Although this begs the question of why you'd need to "rekey" an array...
It seemed the easiest way to get the first two elements off the
beginning of the array after shuffle()ing it, or so I thought -- but I'm
more than happy
On 30/04/2004, at 12:06 PM, John W. Holmes wrote:
Although this begs the question of why you'd need to "rekey" an
array...
It seemed the easiest way to get the first two elements off the
beginning of the array after shuffle()ing it, or so I thought -- but
I'm more than happy to hear of a better
Justin French wrote:
been RTFMing for about 10 minutes, and can't find the function to re-key
an array. In other words, I want an array of items to remain in their
current order, but have the keys renumbered counting from zero.
yes, I know it can be done with a foreach, but I was hoping for
so
http://www.php.net/manual/en/function.array-values.php ?
Richard
Friday, April 30, 2004, 3:48:06 AM, thus was written:
> been RTFMing for about 10 minutes, and can't find the function to
> re-key an array. In other words, I want an array of items to remain in
> their current order, but have th
13 matches
Mail list logo