如何分别在 php 中打印来自 api 的响应
how to print response from an api in php separately
我可以打印来自 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
)
)
)
)
这是我得到的回复 我想单独打印所有字段
这非常简单,只需遵循您从 API
获得的响应结构
试试这个:-
我想你的回复是数组 $reponseArray
foreach($reponseArray['item']->item as $value)
{
foreach($value as $key=>$val)
{
echo $key.' = '. $val;
}
}
我可以打印来自 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
)
)
)
)
这是我得到的回复 我想单独打印所有字段
这非常简单,只需遵循您从 API
获得的响应结构试试这个:-
我想你的回复是数组 $reponseArray
foreach($reponseArray['item']->item as $value)
{
foreach($value as $key=>$val)
{
echo $key.' = '. $val;
}
}