echo an element of an array in php/json
array:
["author"]=> array(1) {
[0] => array(2) {
["name"]=> array(1) {
["$t"]=> string(10) "CALLOFDUTY"
}}}
my code (not working) :
$entry["author"]["0"]["name"]["$t"]
Do you find any开发者_开发问答 errors in the php code above ? whats wrong ? :S
You should use single quotation marks to circumvent problems. Also, you should make sure you use the correct key type - integer 0 is not the same as a character "0".
$entry['author'][0]['name']['$t']
should do the trick.
$
is a special character inside double quotes, if you want to use it as a character you need to escape it: \$
, or use single quotes instead.
As it is your code is looking for an array element with an index whose value is in a variable called $t
Try this one:
$entry["author"][0]["name"]['$t']
精彩评论