Im having difficulties with this loop.
My first array contains lesson details and a lesson code
Second array contains lesson code and states if the lesson is complete “yes” or “no”
I want to array_push this status value to the main lessons array.
Here is my code:
foreach($arrayProgress as $progress){
foreach($arrayLessons as $lesson){
if ($lesson[0] === $progress[0]){
//set checkmark
array_push($arrayLessons, "yes");
}else{
//set checkmark to nothing
array_push($arrayLessons, "no");
}
}
}
Here is the incorrect result. Notice how the yes/no values appear at the END of the main array.
Array (
[0] => Array(
[0] => DRW1L1
[1] => 1
[2] => DRW
[3] => Draw a fish inside a light bulb )
[1] => Array (
[0] => DRW1L2
[1] => 1
[2] => DRW
[3] => How to draw a bee )
[2] => Array (
[0] => DRW1L3
[1] => 1
[2] => DRW
[3] => Drawing two lovebirds )
[3] => Array (
[0] => DRW1L4
[1] => 1
[2] => DRW
[3] => Drawing a cow )
[4] => yes
[5] => no
[6] => no
[7] => no
)
I want it to look like this
Array (
[0] => Array(
[0] => DRW1L1
[1] => 1
[2] => DRW
[3] => Draw a fish inside a light bulb )
[4] => yes
…
…
…
)