Re: Function-return-array idea

From: Date: Thu, 17 Jan 2008 07:31:13 +0000
Subject: Re: Function-return-array idea
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-267480@lists.php.net to get a copy of this message
Stijn Leenknegt wrote: > This is nice, but when I want one element of the returned array, I > have to store the returned array into a variable and then call the > variable. The next code example is my idea. > > <?php > echo getUserInformation($id)['naam']; > ?> > > Let's look further then this small example. > > <?php > echo $object->fetchObjects()[0]->method(); > ?> Yeah, I like the idea. I've often used that style out of habit, only to have to revert to assigning the result to a variable etc. I don't know why it isn't supported by PHP, but I suspect it is related to the type-concept. /Per Jessen, Zürich

« previous php.general (#267480) next »