How can the Modulo function be used to insert a line break after every 10th checkbox in a PHP form?
To insert a line break after every 10th checkbox in a PHP form, we can use the Modulo (%) operator to check if the current checkbox index is divisible by 10. If it is, we can add a line break to the form output. This will ensure that after every 10 checkboxes, a new line is inserted for better readability.
<form>
<?php
for ($i = 1; $i <= 100; $i++) {
echo '<input type="checkbox" name="checkbox'.$i.'"> Checkbox '.$i;
if ($i % 10 == 0) {
echo '<br>'; // Insert line break after every 10 checkboxes
}
}
?>
</form>
Keywords
Related Questions
- How can PHP be used to validate input in a specific date format?
- What best practices should be followed when manipulating timestamps in PHP to ensure accurate date and time representation?
- What are some recommended resources or best practices for implementing Ldap authentication in Silex for users facing complexity or lack of information?