我从以下结果中得到一个数组
echo "<pre>";
print_r($sorted);
echo "</pre>";
结果数组是
Array
(
[0] => stdClass Object
(
[date] => Tue, 17 Nov 2015 15:58:46 +0530
[subject] => one
[toaddress] => ABC
[fromaddress] => QWE
[from] => Array
(
[0] => stdClass Object
(
[personal] => QAZ
[mailbox] => ADS
)
)
)
[1] => stdClass Object
(
[date] => Tue, 16 Nov 2015 15:58:46 +0530
[subject] => two
[toaddress] => hgf
[fromaddress] => mlk
[from] => Array
(
[0] => stdClass Object
(
[personal] => vbn
[mailbox] => zxc
)
)
)
[2] => stdClass Object
(
[date] => Tue, 15 Nov 2015 15:58:46 +0530
[subject] => three
[toaddress] => rty
[fromaddress] => uio
[from] => Array
(
[0] => stdClass Object
(
[personal] => asd
[mailbox] => fgh
)
)
)
)
我希望得到[date],[subject],[personal]的值。我尝试了这个sol,但它没有给出结果。任何人都可以告诉我如何获取这些值
答案 0 :(得分:0)
foreach ($sorted as $item) {
echo $item->date; // holds the date
echo $item->subject; // holds the subject
echo $item->from[0]->personal; // holds personal
// maybe you have to walk through this array too like this
foreach ($item->from as $from) {
echo $from->personal;
}
}