Posted by Daz on 10/14/06 19:54
Chung Leong wrote:
> Hermann.Richter@gmail.com wrote:
> > These array functions: 'each', 'current', 'next', 'end'
> >
> > They return a reference or a value.
>
> They return values.
>
> > let's say I want to modify the last value of an array without iterating
> > through all of them.
> >
> > I would do:
> >
> > <?
> > end($array) ;
> > current($array)="new value" ;
> > ?>
> >
> > is that posible??
>
> Try
>
> end($array);
> $array[key($array)] = "new value";
$array[(sizeof($array)-1)] ="new value";
should also work.
I would imagine that end() and sizeof() work very much the same way.
They probably both iterate through the array to the end only 1 counts
as it goes, and the other returns the key of the last element in the
array.
[Back to original message]
|