数组如下:
$b =
Array (
[0] => WP_Post Object
( [ID] => 11347 [post_author] => 1115 [post_date] => 2013-07-23 11:00:22 [post_date_gmt] => 2013-07-23 03:00:22)
[1] => WP_Post Object
( [ID] => 10591 [post_author] => 90 [post_date] => 2013-06-19 11:00:34 [post_date_gmt] => 2013-06-19 03:00:34)
[2] => WP_Post Object
( [ID] => 10591 [post_author] => 90 [post_date] => 2013-06-19 11:00:34 [post_date_gmt] => 2013-06-19 03:00:34)
)如何取出第二个元素的post_author值啊?这样写不行:print_r($b[1]['post_author'])
$b =
Array (
[0] => WP_Post Object
( [ID] => 11347 [post_author] => 1115 [post_date] => 2013-07-23 11:00:22 [post_date_gmt] => 2013-07-23 03:00:22)
[1] => WP_Post Object
( [ID] => 10591 [post_author] => 90 [post_date] => 2013-06-19 11:00:34 [post_date_gmt] => 2013-06-19 03:00:34)
[2] => WP_Post Object
( [ID] => 10591 [post_author] => 90 [post_date] => 2013-06-19 11:00:34 [post_date_gmt] => 2013-06-19 03:00:34)
)如何取出第二个元素的post_author值啊?这样写不行:print_r($b[1]['post_author'])
echo $b[1]->post_author;//数组里面的都是对象
一维数组里面还有对象的,所以输入的是输出里面的对象。
echo $b[1]->post_author;