どのようにforeachループの配列を数えますか?また、これはこのコードを書いている最善の方法ですか、それとももっとたくさんのcatchallがありますか?私は3次元配列(3つのレベル)を持っています。ここで多次元配列をforeachループ(php)に入れる方法を数えますか?
がしますprint_r
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コードです:
$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>
どのように私はこのforループのために、この配列を数えることができますか?
". 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>";/**/
}
をカウントされるだろう、それはオープンと文の間には密接にしようとして続けました。意味をなさない:) –