Pulling my hair out with this one, please help
I have an array $address
$access=sprintf("['results'][1]['address_components'][1]['long_name']");
I want to be able be able get data from array using the string i.e
$home=$address[$access]
Still having probs
print_r($address['results'][1]['address_components'][1]);
$key=sprintf("[results][1][address_components][1][long_name]");
printf("key=%s\n", $key);
$home = eval($address . $key);
exit;
--- Returns
Array
(
[long_name] => High St
[short_name] => A4151
[types] => Array
(
[0] => route
)
)
key=[results][1][address_components][1][long_name]
PHP Parse error: syntax error, unexpected '[', expecting '(' in /media/www.h.com.dev/postCode/post.php(72) : eval()'d code on line 1
sprintfthat string?