我有这个数组。我尝试了一些东西,但没有得到我想要的。我尝试了一个 foreach 循环,但它似乎并不容易做到,而且这个过程需要很长时间。
stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[display_number] => 100140
[client] => stdClass Object
(
[name] => TAUQIR SHEIKH ET AL
)
)
[1] => stdClass Object
(
[display_number] => 100141
[client] => stdClass Object
(
[name] => YOLANDA SHEIKH ET AL
)
)
我希望它是一个简单的数组
[0] => Array
(
[0] => 100140
[1] => TAUQIR SHEIKH ET AL
)
[1] => Array
(
[0] => 100141
[1] => YOLANDA SHEIKH ET AL
)
好的,所以旧代码可以工作,但现在他们更新了 API,这让情况变得更糟。现在的反应是
(
[data] => Array
(
[0] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[display_number] => 100140
[client] => stdClass Object
(
[name] => TAUQIR SHEIKH ET AL
)
)
[1] => stdClass Object
(
[display_number] => 100141
[client] => stdClass Object
(
[name] => YOLANDA SHEIKH ET AL
)
)
我用新代码试过这个......但数组是空的。我哪里错了?
//clean and make into an array
$matter_array = array();
if(!empty($response_Decode->data->data) &&
is_array($response_Decode->data->data)) {
foreach ($response_Decode->data->data as $info) {
$d = array();
$d[] = $info->display_number;
$d[] = $info->client->name;
$matter_array[] = $d;
}
}
print_r($matter_array); //For testing
die(); //For testing