3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = [ (object)['menu_id' => 1, 'menu_name' => 'one'], (object)['menu_id' => 2, 'menu_name' => 'two'], (object)['menu_id' => 3, 'menu_name' => 'three'], ]; ?> <form action=""> <table> <thead> <tr> <th>Menu Id</th> <th>Menu Name</th> <th>Yes/No</th> </tr> </thead> <tbody> <?php foreach($result as $res) { ?> <tr> <td><?= $res->menu_id ?></td> <td><?= $res->menu_name ?></td> <td><input type="checkbox" name="yes[<?= $res->menu_id ?>]" value="1"></td> </tr> <?php } ?> </tbody> </table>
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<form action=""> <table> <thead> <tr> <th>Menu Id</th> <th>Menu Name</th> <th>Yes/No</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>one</td> <td><input type="checkbox" name="yes[1]" value="1"></td> </tr> <tr> <td>2</td> <td>two</td> <td><input type="checkbox" name="yes[2]" value="1"></td> </tr> <tr> <td>3</td> <td>three</td> <td><input type="checkbox" name="yes[3]" value="1"></td> </tr> </tbody> </table>

preferences:
102.87 ms | 1705 KiB | 4 Q