Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I use this in wordpress:

$arr=get_post_meta($post->ID, false);

I receive this array:

Array (
[_edit_last] => Array ( [0] => 2)
[year_completed] => Array ( [0] => 2010 )
[designers] => Array ( [0] => )
[developers] => Array ( [0] => )
[producers] => Array ( [0] => )
[_edit_lock] => Array ( [0] => 1298159324 )
[name_en] => Array ( [0] => game 1)
[name_et] => Array ( [0] => game 2 )
[friends_meta] => Array ( [0] => )
)

How do I echo (no for, foreach, etc please) name_en data? Even print_r ($arr->name_en); doesn't work... I suppose it has to be something like - echo $arr->name_en[0]; ???

share|improve this question

It is an array or arrays, so:

print_r($arr['name_en']);

or if you only want to get the data:

echo $arr['name_en'][0];

The -> operator is for accessing properties of objects.

share|improve this answer
    
Yep, so it's echo $arr['name_en'][0]; Thanks ;) – user6291275 Feb 20 '11 at 0:45

echo $arr['name_en'][0] should work.

share|improve this answer

this should work

echo $arr[0]['year_completed'];

echo $arr[0]['designers'];

etc

share|improve this answer
    
While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, as this reduces the readability of both the code and the explanations! – FrankerZ Aug 13 at 8:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.