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;
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题