I tried to use for-loop/foreach inside array_filter(). but the for loop/foreach doesn't work inside array_filter(). How can I use for-loop/foreach inside array_filter()?
$bookingData = array_values(array_filter($jsonBooking, function($bookingItem) {
foreach ($orderData as $orderItem) {
if ($bookingItem['order_id'] === $orderItem['id']) {
return $bookingItem;
}
}
}
return bookingItemshould have had a$, and that should have given an error for "undefined constant". Along with the fact that$orderDatawas undefined. Are you developing without error reporting on?