let me start with the array structure that I am sending from the backend to the frontend view :
Code: Select all
$allParamValues=Array
(
[CATEGORY] => Array
(
[displayValue] => Array
(
//[key] => [value]
)
[backendValue] => Array
(
//[key] => [value]
)
)
[ORIENTATION] => Array
(
//Array similiar to above
)
[CARRIER_DECK] => Array
(
//array similiar to above
)
[POSITION] => Array
(
//array similiar to above
)
)
Now these key fields and checkbox values are dynamic and they are actually read from a .csv file , as such I have to keep my design layout flexible such that if tomorrow there are only 3 or 5 key fields , my table structure will be adjsted accordingly .
In the html view , I am using the following php loops :
Code: Select all
<?php
$countCells = 2;
$totalNoOfRows = ceil(count($allParamValues)/2);
for($j=0;$j<$totalNoOfRows;$j++)
{
echo "<tr>";
$allParamVAluesTmp = array_slice($allParamValues,$countCells*$i,$countCells);
foreach($allParamVAluesTmp as $category=>$optionsArr)
{
?>
<!--create the tds-->
<table>
<?php
//breaks $optionsArray above to keep 2 checkboxes per row using
// the same array_slice
// which results in 1 for loop and 1 interior foreach loop.
?>
<?php echo '</tr>'; ?>will converting array_slice to array_chunk do any difference ?