Edit report at https://bugs.php.net/bug.php?id=65380&edit=1
ID: 65380 User updated by: cgray at metamedia dot us Reported by: cgray at metamedia dot us Summary: Unable to post note to manual documentation page -Status: Feedback +Status: Open Type: Bug Package: Website problem Operating System: n/a PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Yes, you understanding of the report is correct. Using my email address @metamedia.us Below is what I was attempting to post. thanks -c! ----- Returning values from a multidimensional array based using variable variables and infinite key depth I banged my head against this but could not find a way in language structure or in functions to retreive a value from a multidimensional array where the key path is known as a variable string. I considered some sort of recursive function, but it seemed cumbersome for what should be a one-liner. My solution uses eval() to return the array value: <?php $geolocation = array("ip"=>"127.0.0.1", "location" => array("city" => "Knoxville", "state_province" => "TN", "country" => "USA")); print_r($geolocation); // Array ( [ip] => 127.0.0.1 [location] => Array ( [city] => Knoxville [state_province] => TN [country] => USA ) ) // typical use of variable variables $key = "ip"; $result = $geolocation[$key]; print_r($result); // 127.0.0.1 $key = "location"; // another typical use of variable variables $result = $geolocation[$key]; print_r($result); // Array ( [city] => Knoxville [state_province] => TN [country] => USA ) // but how do we go deeper? this does NOT work $key = "location['city']"; // $result = $geolocation[$key]; // Notice: Undefined index: location['city'] // print_r($result); // this does NOT work $key = "['location']['city']"; // $result = $geolocation{$key}; // Notice: Undefined index: ['location'] ['city'] // print_r($result); // this works: $key = "['location']['city']"; $result = eval('echo $geolocation'."$key;"); print_r($result); // Knoxville ?> Previous Comments: ------------------------------------------------------------------------ [2013-08-03 07:02:23] google...@php.net I'm not sure I'm clear on the parameters of the bug you're trying to report. Are you saying you attempted to submit to the user contributed notes and received a spam error? Can you provide the note you attempted to submit and email you used (if any)? There are certain things that can trigger the spam filter and yours may have gotten caught there. ------------------------------------------------------------------------ [2013-08-02 14:57:22] cgray at metamedia dot us Description: ------------ Attempted to post a note multiple times to page: http://php.net/manual/en/language.variables.variable.php but always fail spam test. Bottom of page: "This mirror generously provided by: Yahoo! Inc." I would like to contribute and payback help I have found via article notes by others. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65380&edit=1 -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php