I'm trying to output my multi array in a nice format so i can read it easily
Here's my array code:
$weekly_array = array
(
"Sunday" => array( "OT" => $sundayOT,
"LIEU" => $sundayLIEU,
"TOTAL" => $sundayOT+$sundayLIEU,
"STAT" => $sundaySTAT,
"WEEKDAY" => 0),
"Monday" => array( "OT" => $mondayOT,
"LIEU" => $mondayLIEU,
"TOTAL" => $mondayOT+$mondayLIEU,
"STAT" => $mondaySTAT,
"WEEKDAY" => 1),
"Tuesday" => array( "OT" => $tuesdayOT,
"LIEU" => $tuesdayLIEU,
"TOTAL" => $tuesdayOT+$tuesdayLIEU,
"STAT" => $tuesdaySTAT,
"WEEKDAY" => 1),
"Wednesday" => array( "OT" => $wednesdayOT,
"LIEU" => $wednesdayLIEU,
"TOTAL" => $wednesdayOT+$wednesdayLIEU,
"STAT" => $wednesdaySTAT,
"WEEKDAY" => 1),
"Thursday" => array( "OT" => $thursdayOT,
"LIEU" => $thursdayLIEU,
"TOTAL" => $thursdayOT+$thursdayLIEU,
"STAT" => $thursdaySTAT,
"WEEKDAY" => 1),
"Friday" => array( "OT" => $fridayOT,
"LIEU" => $fridayLIEU,
"TOTAL" => $fridayOT+$fridayLIEU,
"STAT" => $fridaySTAT,
"WEEKDAY" => 1),
"Saturday" => array( "OT" => $saturdayOT,
"LIEU" => $saturdayLIEU,
"TOTAL" => $saturdayOT+$saturdayLIEU,
"STAT" => $saturdaySTAT,
"WEEKDAY" => 0)
);
Here's my code for output:
echo "<pre>" ;
echo "Day \t OT \t LIEU \t TOTAL \t STAT \t WEEKDAY";
array_map(function ($var) {
echo "
", $weekly_array[0], "\t", $var['OT'], "\t", $var['LIEU'], "\t", $var['TOTAL'], "\t", $var['STAT'], "\t", $var['WEEKDAY'];
}, $weekly_array);
echo "</pre>";
Everything works but I can't get the week days to show (Sunday, Monday, etc...) - I tried $weekly_array[0]
to display Sunday then Monday and so on for each line but it gives error: Notice: Undefined variable: weekly_array
Anyone know what i'm doing wrong ??