Urgent help required in php coding to display checkboxes in 5/5 format

hi there im a newbie and new to this forum and need the help from this community to solve my issue i have a function which displays checkboxes but it is not formatted properly it is come one by one and grouped together
plz help me with the proper logic code to arrange the list of checkboxes in 5/5 format my current code which is not displaying the layout of the checkboxes properly is :

function checkBoxList( &$arr, $tag_name, $tag_attribs, $selected=null, $key=‘value’, $text=‘text’, $porlinea=false )
{
reset( $arr );
$html = “”;
for ($i=0, $n=count( $arr ); $i < $n; $i++ ) {

	  $k = $arr[$i]-&gt;$key;
	  $t = $arr[$i]-&gt;$text;
	  $id = @$arr[$i]-&gt;id;

plz reply me with the proper logic code to display these checkboxes in a proper format of 5/5

When every fifth checkbox occurs, you can use the % operator to add extra code to add a break to the list of checkboxes.

for example:


for (...) {
    ...
    if ($i > 0 && $i % 5 === 0) {
        echo '<br>';
    }
}

This works because 5 % 5 = 0, and 6 % 5 = 1, so when %i is a multiple of 5, $i % 5 will equal 0, letting you know that it’s the right time to add another break.

put if condition in for loop that checks the no of checkbox to display in a row.

if($i !=0 && $i % 5==0){

}

Above code will check for five checkbox to display in a row.