我有一些API以JSON格式返回结果我成功地将其转换为多维数组。
Array
(
[status] => success
[cdr] => Array
(
[0] => Array
(
[date] => 2017-04-01 05:14:00
[callerid] => "ABC" <61344341227>
[destination] => 1604535320207
[description] => ABC1
[account] => ABC1
[disposition] => ANSWERED
[duration] => 10:57:57
[seconds] => 437
[rate] => 0.00200000
[total] => 0.06480000
[uniqueid] => 105943343
)
[1] => Array
(
[date] => 2017-04-11 05:10:00
[callerid] => "XYZ" <61343241227>
[destination] => 16045353250207
[description] => XYZ1
[account] => XYZ1
[disposition] => ANSWERED
[duration] => 13:57:57
[seconds] => 447
[rate] => 0.01100000
[total] => 0.06411000
[uniqueid] => 105911143
)
)
)
请帮助我在行/列中获取数据。
我写了下面的代码,但它说的是未定义的偏移....
foreach( $curl_jason as $key => $value)
{
echo $key;
echo $value['callerid'];
}
答案 0 :(得分:3)
试试这个:
foreach( $curl_jason['cdr'] as $data)
{
echo $data['callerid']; // will print callerid value
}