Edit report at https://bugs.php.net/bug.php?id=65380&edit=1

 ID:                 65380
 Updated by:         bj...@php.net
 Reported by:        cgray at metamedia dot us
 Summary:            Unable to post note to manual documentation page
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Website problem
 Operating System:   n/a
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Its intentionally vague. We want to make sure you've read the rules of 
engagement and the entire page clearly before adding user contributed content :)

This happens every once in a while for the best of us, but it helps weed out 
silly comments and rage flooding


Previous Comments:
------------------------------------------------------------------------
[2013-08-05 14:52:57] cgray at metamedia dot us

OK, sorry for wasting your time.

Perhaps this should be a web site UI enhancement request.

Either accept numerical as well as spellings for answers, or make the expected 
response more explicit.

thanks!

------------------------------------------------------------------------
[2013-08-05 14:38:52] sala...@php.net

Only as dim as I was!  There is a hint, but it is out of the way (on larger 
screens).

See http://i.imgur.com/aSEGMcU.png

------------------------------------------------------------------------
[2013-08-05 14:28:55] cgray at metamedia dot us

I was entering numbers as my challenge response (did not see any direction to 
SPELL the numeric answers (?)). Am I being dim here?

Public IP: 67.187.112.122

------------------------------------------------------------------------
[2013-08-05 14:20:08] sala...@php.net

I successfully managed to submit the quoted text using your email address 
(whilst logged out from php.net) without 
issue.  See http://news.php.net/php.notes/195872

However, I did stumble once on the spam challenge... twice. It was like 
"min(three, eleven)" and I answered with a 
number "3" instead of the word "three".  Were you doing the same as I did?

If not, then the email/content of the note doesn't seem to prevent it from 
getting posted, which (barring the above 
user error) would make it look like a DNS blacklist issue. If this might be the 
case, could you provide your public-
facing IP address?

------------------------------------------------------------------------
[2013-08-05 13:24:41] cgray at metamedia dot us

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

?>

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=65380


-- 
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

Reply via email to