I got a problem here, why my array cannot go through foreach ? This is my code, I wonder why it says invalid argument. Please help me, thank you.
source
/*some of block code here*/
$content = array();
$content['table_1'] = array();
$columns = array('B', 'E', 'H', 'K');
$rows = array(
0 => 7,
1 => 8,
2 => 9,
3 => 10,
);
foreach ($columns AS $column) {
foreach ($rows AS $row_key => $row_value) {
$content['table_1'][$column . $row_value] = $data['jenis_kelamin']['l']['count'][$row_key];
}
}
$columns = array('C', 'F', 'I', 'L');
foreach ($columns AS $column) {
foreach ($rows AS $row_key => $row_value) {
$content['table_1'][$column . $row_value] = $data['jenis_kelamin']['p']['count'][$row_key];
}
}
return $content;
print file
$tableContent = $this->cetak->Statistik_Content()['table_1'];
if (is_array($tableContent) || $tableContent instanceof Traversable) {
foreach ($tableContent AS $list) {
foreach ($list AS $key => $value) { // **This one generates an error**
$this->excel->getActiveSheet()->setCellValue($key, $value);
}
}
}
If I check it with is array, the condition true, but when I try to put it in foreach, it says invalid, I have no idea, I already look into this problem for hours and still can't fix it.
Var Dump $tableContent
array(32) { ["B7"]=> int(0) ["B8"]=> int(0) ["B9"]=> int(1) ["B10"]=> int(1) ["E7"]=> int(0) ["E8"]=> int(0) ["E9"]=> int(1) ["E10"]=> int(1) ["H7"]=> int(0) ["H8"]=> int(0) ["H9"]=> int(1) ["H10"]=> int(1) ["K7"]=> int(0) ["K8"]=> int(0) ["K9"]=> int(1) ["K10"]=> int(1) ["C7"]=> int(0) ["C8"]=> int(0) ["C9"]=> int(1) ["C10"]=> int(0) ["F7"]=> int(0) ["F8"]=> int(0) ["F9"]=> int(1) ["F10"]=> int(0) ["I7"]=> int(0) ["I8"]=> int(0) ["I9"]=> int(1) ["I10"]=> int(0) ["L7"]=> int(0) ["L8"]=> int(0) ["L9"]=> int(1) ["L10"]=> int(0) }