View Single Post

  #2 (permalink)  
Old 10-14-2006
Chung Leong
 
Posts: n/a
Default Re: Return value of 'each', 'current', 'next', 'end'

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";

Reply With Quote