배열에서 foreach 루프를 계산하려면 어떻게합니까? 또한,이 코드를 작성하는 가장 좋은 방법입니까, 아니면 더 많은 catchall입니까? 3 차원 배열 (3 단계)이 있습니다.다차원 배열을 foreach 루프 (PHP)에 포함시키는 방법은 무엇입니까?
$newArray = [];
foreach($requirements as $key => $value){
$newArray[] = $value['audit_inspectionID'];
$newArray[] = $value['requirement'];
$newArray[] = $value['class_answer'];
$newArray[] = $value['repeat_answer'];
$newArray[] = $value['class_answer'];
$newArray[] = $value['actionID'];
$newArray[] = $value['action_link'];
print "<div id='inspection_view" . $value['audit_inspectionID'] . "' style='display:inline'>
<table id='actions_table' class='table table-bordered table-condensed table-striped bg-info'>
<thead>
<th align='center'>" . value['requirement'] . " </th>
". if ($corporate_admin == 'true') { ."
<a id='" . $value['audit_inspectionID'] . "' class='btn btn-danger pull-right remove1' href=' + '#' + '>Remove</a><a id='edit" . $value['audit_inspectionID'] ."' class='btn btn-warning pull-right edit1' href=#>Edit</a></th>
". } ."
</thead><tbody>
<tr>
<td>
가 어떻게 루프 배열이 본 셀 수 : 여기
여기Array
(
[0] => Array
(
[0] => 17
[audit_inspectionID] => 17
[1] => 2016-08-15
[created] => 2016-08-15
[2] => 2016-08-15 09:52:28
[modified] => 2016-08-15 09:52:28
[class_answer] => Array
(
[0] => Needs Improvement
[1] => Need To Correct
[2] => Needs Immediate Action
)
)
)
PHP 코드가 인 print_r
의 일례이다? ". for (x = 0; x< count($value[class_answer]) ; x++){
$value[class_answer]
} ."
<br>
". $value[repeat_answer] ."
<br>
". if ($value[actionID] != 0) {
$value[action_link]
} ."
</td>
</tr>
</tbody>
</table>
</div>";/**/
}
계산되어 $ 값 [class_answer]의 요소의
수를 할 것입니다. 말이된다. :) –