在php中从数组中获取值

在php中从数组中获取值,php,arrays,object,multidimensional-array,Php,Arrays,Object,Multidimensional Array,我从下面的结果中得到一个数组 echo "<pre>"; print_r($sorted); echo "</pre>"; 我希望获得[日期]、[主题]、[个人]的值。我试过了,但没有结果。谁能告诉我如何获取这些值您是如何获取这些数据的?如果将JSON数组转换为PHP数组,则应使用JSON\u decode($array,true)删除“stdClass Object”数组values@BenPearl Kahan我从imap获得结果,然后转换为array@B

我从下面的结果中得到一个数组

echo "<pre>";
    print_r($sorted);
echo "</pre>"; 

我希望获得[日期]、[主题]、[个人]的值。我试过了,但没有结果。谁能告诉我如何获取这些值

您是如何获取这些数据的?如果将JSON数组转换为PHP数组,则应使用
JSON\u decode($array,true)
删除“stdClass Object”数组values@BenPearl Kahan我从imap获得结果,然后转换为array@BenPearlKahan这有什么区别<代码>$array[0]->日期vs
$array[0]['date']
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
                            )

                    )
            )
    )
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;
  }
}