愚蠢的问题。下面是我的阵列。我得到了第一个维度,返回到带有foreach循环的表格,如何迭代' work_order_status'数组的一部分能够将其设置为表值吗?
Array
(
[transaction_id] => 2014102413362746N1SSCSYY9PFSUS85-0
[response_code] => 200
[work_order] => 151262
[percent_complete] => 100
[duplicate_records] => 0
[work_order_status] => Array
(
[record] => Array
(
[0] => Array
(
[record_count] => 1590
[percent_of_total] => 40.52
[description] => Successful delivery
)
[1] => Array
(
[record_count] => 2
[percent_of_total] => .05
[description] => Invalid Number - too short
)
[2] => Array
(
[record_count] => 2
[percent_of_total] => .05
[description] => Invalid Number - Illegal NPA-NXX
)
[3] => Array
(
[record_count] => 2
[percent_of_total] => .05
[description] => Invalid Number - NULL submission
)
[4] => Array
(
[record_count] => 1
[percent_of_total] => .03
[description] => Invalid Number - Not a dialable number
)
[5] => Array
(
[record_count] => 996
[percent_of_total] => 25.38
[description] => Invalid Request - not a WIRELESS number
)
[6] => Array
(
[record_count] => 867
[percent_of_total] => 22.09
[description] => Max Account Retries Exceeded
)
[7] => Array
(
[record_count] => 18
[percent_of_total] => .46
[description] => Voicemail delivery unconfirmed
)
[8] => Array
(
[record_count] => 3
[percent_of_total] => .08
[description] => Voicemail played for 0 seconds
)
[9] => Array
(
[record_count] => 341
[percent_of_total] => 8.69
[description] => Voicemail played for less than message length.
)
[10] => Array
(
[record_count] => 18
[percent_of_total] => .46
[description] => No Answer
)
[11] => Array
(
[record_count] => 76
[percent_of_total] => 1.94
[description] => Network Disconnect (FEHU)
)
[12] => Array
(
[record_count] => 8
[percent_of_total] => .2
[description] => Duplicate Records
)
)
)
)
答案 0 :(得分:3)
您可以使用foreach循环,例如:
foreach($array['work_order_status'] as $value) {
//some code here
}
或者如果数组的['record']
部分实际上是你要迭代的部分,那么你可以这样做:
foreach($array['work_order_status']['record'] as $value) {
//some code here
}
评论后编辑:
foreach ($xml2['work_order_status']['record'] as $value) {
echo "<td>" . $xml2 . "</td>" .
"<td>" . $value['record_count'] . "</td>" .
"<td>" . $value['percent_of_total'] . "</td>" .
"<td>" . $value['description'] . "</td><tr>";
}
答案 1 :(得分:0)
foreach ($xml2['work_order_status']['record'] as $key =>$value) {
echo "<td>" . $xml2 . "</td><td>" . $value['record_count'] . "</td><tr>" . "<td>" . $xml2 . "</td><td>" . $value['percent_of_total'] . "</td><tr>" . "<td>" . $xml2 . "</td><td>" . $value['description'] . "</td><tr>";
}