如何處理使用多個(gè)foreach循環(huán)?但是,它給出了 16 行,而只有它應(yīng)該給出 4 行- 因?yàn)樗鼤?huì)多次重復(fù)輸入。簡(jiǎn)而言之,我從 MySQL 讀取所有子類別并標(biāo)記之前已通過(guò)復(fù)選框選中的所有子類別,然后全部更新。我在這里做錯(cuò)了什么 - 感謝任何幫助。謝謝。目前我有:<div class="form-group"> <div class="col-xm-12"> <div class="table-responsive"> <table class="table table-bordered table-striped" role="grid"> <tbody> <tr> <td> <?php $valuesub = ($page->subcat_recip_id); $array_of_values = explode(",", $valuesub); foreach ($menu_links as $item): if ($item['parent_id'] != "0" && $item['subcat_recip_id'] == "0"):?> <?php foreach($array_of_values as $dt): ?> <input type="checkbox" name="subcat_recip_id" class="square-purple" value="<?php echo html_escape($item["title"]); ?>" <?=(in_array($dt, $item)) ? "CHECKED" : ""?>> <?=html_escape($item["title"]); ?> <?php endforeach;endif;endforeach; ?> </td><?php echo html_escape($valuesub); ?> </tr> </tbody> </table> </div> </div></div>示例數(shù)組$array_of_values包含:array(4) { [0]=> string(10) "Appetizers" [1]=> string(9) "Beverages" [2]=> string(7) "Dessert" [3]=> string(5) "Bread" }
- 1 回答
- 0 關(guān)注
- 229 瀏覽
添加回答
舉報(bào)
0/150
提交
取消