开发者

PHP, how to echo specific object data from array?

开发者 https://www.devze.com 2023-02-11 07:04 出处:网络
I use this in wordpress: $arr=get_post_meta($post->ID, false); I receive this array: Array ( [_edit_last] => Array ( [0] => 2)

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]; ???


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.


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


this should work

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

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

etc

0

精彩评论

暂无评论...
验证码 换一张
取 消