I am trying to run an array_search on a foreach loop
$i=0;
foreach(findCustomAlerts($customerid) as $key=>$value){
echo "ID of cat : ".$rifdid[$i++] = $value['Catid']."<br>";
echo "Visits required per day : ".$visitsneeded= $value['Visits required']."<br>";
}
echo "<pre>";
print_r($rifdid);
echo "</pre>";
foreach(getTodaysVisits($device_id) as $rfid){
foreach($rfid as $key=> $read){
//echo $key."<br>";
//$i=0;
if(array_search($key,$rifdid) && $read < $visitsneeded) {
echo $key." has not visited enough";
// $i++;
}
}
}
The data for the first for each loop is as follows:
Array ( [0] => Array ( [Alertid] => 4 [Catid] => 5609 [Visits required] => 6 ) [1] => Array ( [Alertid] => 5 [Catid] => 23641 [Visits required] => 5 ) )
The data for the second foreach is as follows:
Array ( [rfid_id] => Array ( [23641] => 1 [5609] => 3 ) )
I want to compare the two arrays, and where the rfid id has not reached the required number of visits for that day I need to perform another action.
At the moment when I run the code, it is only picking up that the RFID id 23641 hasnt had enough visits that day, when it should be picking up that both rfids have not been seen enough
This is the current output: ID of cat : 5609 Visits required per day : 6 ID of cat : 23641 Visits required per day : 5 23641 has not visited enough
It also needs to output 5609 has not visited enough.