opensubscriber
   Find in this group all groups
 
Unknown more information…

p : php-general@lists.php.net 12 September 2009 • 1:32PM -0400

Re: [PHP] get an object property
by Lars Torben Wilson

REPLY TO AUTHOR
 
REPLY TO GROUP




Tom Worster wrote:
> if i have an expression that evaluates to an object, the return value from a
> function, say, and i only want the value of one of the objects properties,
> is there a tidy way to get it without setting another variable?
>
> to illustrate, here's something that doesn't work, but it would be
> convenient if it did:
>
> $o = array( (object) array('a'=>1), (object) array('a'=>2) );
>
> if ( end($o)->a > 1 ) {  // can't use -> like this!
> ...
> }

What version of PHP are you using? Your example should work.


Torben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.