duan117890 2015-02-20 09:48
浏览 21
已采纳

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

i am able to print the response from an api but it is nested array i am not able to save it.

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

This is the response i am getting i want to print all fields separately

  • 写回答

1条回答 默认 最新

  • dtpxi88884 2015-02-20 10:04
    关注

    This very simple just follow the structure of response which you are getting from API

    Try this:-

    I suppose your repsonse in a array $reponseArray

    foreach($reponseArray['item']->item as $value)
    {
      foreach($value as $key=>$val)
      {
        echo $key.' = '. $val;
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效