Page 1 of 1

Functions returning arrays

Posted: Tue Sep 23, 2008 3:29 am
by Glycerine
U have a function of which returns an array - simple enough.

Is there a way to reference it by simply:

Code: Select all

$myvar = somefunc()[0]
Thanks in advance.

Re: Functions returning arrays

Posted: Tue Sep 23, 2008 4:13 am
by shaneiadt

Code: Select all

$myvar = somefunc()[0];
Nope you can't do this!! Just assign the returned array to an array variable;

Code: Select all

 
$myarray = someFunc();
$myvar = $myarray[0];
 
Then you can use $myvar variable as normal;
echo $myvar;
or whatever valid way you want to do it :)

Re: Functions returning arrays

Posted: Sat Sep 27, 2008 2:44 pm
by Glycerine
cool. I thought as much. I was just trying to find a prettier way to reference an array return from a function