#41268 [Opn->Bgs]: Access array member without variable

From: Date: Thu, 03 May 2007 12:15:16 +0000
Subject: #41268 [Opn->Bgs]: Access array member without variable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112202@lists.php.net to get a copy of this message
ID: 41268 Updated by: johannes@php.net Reported By: viktor_b_68 at passagen dot se -Status: Open +Status: Bogus Bug Type: Feature/Change Request PHP Version: 5.2.1 New Comment: This was discussed multiple times before and was rejected. Please check the archives of php-internals to get further details. btw. You can easily implement your array_value() function yourself. We won't add simple array functions. Previous Comments: ------------------------------------------------------------------------ [2007-05-03 12:06:52] viktor_b_68 at passagen dot se Description: ------------ When you get a reference to an array, by a function, there is no way to access any certain member of the array. With this function given: <?php function get_array() { return array("foo" => "FOO", "bar" => "BAR"); } ?> there is no way to do: <?php print get_array()["foo"] ?> You have to do like this: <?php $array = get_array(); print $array["foo"]; ?> There should be a way to access a member of the array in only one expression, without the need for assigning a variable. Either by using the first syntax above, or if you don't like the looks of it, maybe a function like this: <?php print array_value(get_array(), "foo") ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41268&edit=1

« previous php.bugs (#112202) next »