I am trying to find the difference between an array of a list of all activities and a list of all of the done activities that will yield a list of all activities that is not yet done.
here is my PHP code for these 2 arrays:
$sql=" SELECT * FROM milestone
WHERE month BETWEEN '$age' - 3 AND '$age' + 3
ORDER BY month";
$result=mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result)) {
$allMilestone[] = $row;
}
$sql=" SELECT milestone.* FROM `milestone`
LEFT JOIN `milestone_transaction`
ON milestone.stone_id = milestone_transaction.stone_id
WHERE milestone_transaction.registration_no = 1111;";
$result=mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result)) {
$checkedMilestone[] = $row;
}
I am using the custom function for array recursive difference provided by several sources like recursive array_diff()? but it is not working for my case.
I have also print_r the output for allMilestone, checkedMilestone & list:
$allMilestone: Array ( [0] => Array ( [0] => fm1 [stone_id] => fm1 [1] => 3 [month] => 3 [2] => Follow past midline [criteria] => Follow past midline ) [1] => Array ( [0] => fm2 [stone_id] => fm2 [1] => 3 [month] => 3 [2] => Sit look for yarn [criteria] => Sit look for yarn ) [2] => Array ( [0] => gm1 [stone_id] => gm1 [1] => 3 [month] => 3 [2] => Prone lifts head [criteria] => Prone lifts head ) [3] => Array ( [0] => gm2 [stone_id] => gm2 [1] => 3 [month] => 3 [2] => Sit head steady [criteria] => Sit head steady ) [4] => Array ( [0] => hl1 [stone_id] => hl1 [1] => 3 [month] => 3 [2] => Vocalises, not cry [criteria] => Vocalises, not cry ) [5] => Array ( [0] => hl2 [stone_id] => hl2 [1] => 3 [month] => 3 [2] => Laughs [criteria] => Laughs ) [6] => Array ( [0] => ps1 [stone_id] => ps1 [1] => 3 [month] => 3 [2] => Smile responsively [criteria] => Smile responsively ) [7] => Array ( [0] => ps2 [stone_id] => ps2 [1] => 3 [month] => 3 [2] => Resists toy pull [criteria] => Resists toy pull ) )
$checkedMilestone: Array ( [0] => Array ( [0] => hl1 [stone_id] => hl1 [1] => 3 [month] => 3 [2] => Vocalises, not cry [criteria] => Vocalises, not cry ) [1] => Array ( [0] => ps1 [stone_id] => ps1 [1] => 3 [month] => 3 [2] => Smile responsively [criteria] => Smile responsively ) )
the difference array: Array ( [0] => Array ( [0] => fm1 [stone_id] => fm1 [2] => Follow past midline [criteria] => Follow past midline ) [1] => Array ( [0] => fm2 [stone_id] => fm2 [2] => Sit look for yarn [criteria] => Sit look for yarn ) [2] => Array ( [0] => gm1 [stone_id] => gm1 [1] => 3 [month] => 3 [2] => Prone lifts head [criteria] => Prone lifts head ) [3] => Array ( [0] => gm2 [stone_id] => gm2 [1] => 3 [month] => 3 [2] => Sit head steady [criteria] => Sit head steady ) [4] => Array ( [0] => hl1 [stone_id] => hl1 [1] => 3 [month] => 3 [2] => Vocalises, not cry [criteria] => Vocalises, not cry ) [5] => Array ( [0] => hl2 [stone_id] => hl2 [1] => 3 [month] => 3 [2] => Laughs [criteria] => Laughs ) [6] => Array ( [0] => ps1 [stone_id] => ps1 [1] => 3 [month] => 3 [2] => Smile responsively [criteria] => Smile responsively ) [7] => Array ( [0] => ps2 [stone_id] => ps2 [1] => 3 [month] => 3 [2] => Resists toy pull [criteria] => Resists toy pull ) )
Can you help me by pointing where I went wrong, as people said that the custom function works properly for them.