如何分别从php中的api打印响应

时间:2015-02-20 09:48:20

标签: php arrays api printing response

我能够从api打印响应,但它是嵌套数组,我无法保存它。

    Array
 (
   [statuscode] => 0
   [status] => SUCCESS
   [item] => SimpleXMLElement Object
      (
        [item] => Array
            (
                [0] => SimpleXMLElement Object
                    (

                        [BENEID] => 227287
                        [BENENAME] => test
                        [BANKNAME] => test
                        [BRANCHNAME] => test
                        [CITY] => test
                        [STATE] => tetst
                        [IFSCCODE] => HBNB
                        [ACCOUNTNO] => 4545345
                        [MMID] => SimpleXMLElement Object

                       (
                                [0] =>  
                        )

                        [MOBILE] => 0
                        [BENESTATUS] => Approved
                        [MMIDSTATUS] => 0
                        [IFSCSTATUS] => 1
                        [IMPSMMIDENABLE] => 0
                        [IMPSIFSCENABLE] => 0
                        [IMPSNEFTENABLE] => 1
                        [DELETESTATUS] => 0
                    )
                  )
               )
           )

这是我想要分别打印所有字段的响应

1 个答案:

答案 0 :(得分:0)

这非常简单,只需遵循您从API获得的响应结构

试试这个: -

我想你在阵列中的回复 $ reponseArray

foreach($reponseArray['item']->item as $value)
{
  foreach($value as $key=>$val)
  {
    echo $key.' = '. $val;
  }
}