I've got an array which points to a bunch of other arrays, structured like a JSON object. This is the structure of it:
$allRows= array(
"Global task 1"=> array(
"major-task"=> array(
"points"=> 850,
),
"minor-task"=> array(
array(
"points"=> 400,
"task"=> "Minor task 1",
),
array(
"points"=> 200,
"task"=> "Minor task 2",
),
array(
"points"=> 250,
"task"=> "Minor task 3",
),
)
),
"Global task 2"=> array(
"major-task"=> array(
"points"=> 850,
),
"minor-task"=> array(
array(
"points"=> 400,
"task"=> "Minor task 1",
),
array(
"points"=> 200,
"task"=> "Minor task 2",
),
array(
"points"=> 250,
"task"=> "Minor task 3",
),
)
),
);
I'm trying to be able to access each of these in the following way:
foreach ($allRows as $row) {
// Print Global task 1, Global task 2, etc
echo $row[0]; // unsure how to acquire this 'Global task x' text
// I've already accessed this just fine
echo $row["major-task"]["points"];
}
I've got the latter echo just fine, but I'm unable to print the Global task 1 and Global task 2. Any help printing this text would be highly appreciated!
foreach ($allRows as $taskName => $row){ // result here ! }