Can I use arrays as array values? I have lots of rows in a HTML table: only first column and other columns data array is changing.
I've tried following code but it seems not working.
$period['areas']['AREA I'] = "Area 1";
$period['areas']['AREA II'] = "Area 2";
// and so on...
$customerCountTotal = array();
$customerCountTotal[1]['AREA I'] = 700;
$customerCountTotal[1]['AREA II'] = 500;
$customerCountActive[1]['AREA I'] = 300;
// and so on...
for ($counter = 1; $counter <= 7; $counter++) {
$rowArray = array("Customers" => $customerCountTotal, "– active customers" => $customerCountActive /* etc. */);
foreach ($rowArray as $key => $value) {
echo "<tr>";
echo "<th>" . $key . "</th>";
echo "<td style='text-align: right;'>" . $key . "</th>";
if(isset($period['areas'])) {
foreach ($period['areas'] as $key2 => $value2) {
echo "<td style='text-align: right;'>".$value[$counter][$key2]."</td>";
}
}
echo "</tr>";
}
}
There might be a better way to do this. Thanks in advance.