[UPHPU] Accessing an element in an array returned from a function

Richard K Miller richardkmiller at gmail.com
Thu Jan 29 19:13:46 MST 2009


> If abc() returns an array, is there any possible notation that lets  
> me access a single element?
>   echo abc()[0];   // I wish this were possible
> ...instead of having to use an intermediate variable?
>   $temp = abc();   // $temp is ugly
>   echo $temp[0];
>
> echo current(abc());
>
> Maybe it will be faster if you use the temp (ugly) variable than  
> call a method :]
>

The only optimizations I'm concerned with in this example are  
aesthetics and my own sanity. It just looks so ugly to use a temp  
variable.




More information about the UPHPU mailing list