This is my JSON.
Stored in variable named $onceBooking.
I want to get booking_slots from each booking.
This is my code:
for ($i = 0; $i < count($onceBooking); $i++) {
if (count($onceBooking[$i]->bookings) == 0) {
$onceBooking[$i]->total_days = 0;
} else {
$onceBooking[$i]->total_days = count($onceBooking[$i]->bookings);
$bookings = $onceBooking[$i]->bookings;
for ($j = 0; $j < count($bookings); $j++) {
return $bookings[$j]->booking_slots;
}
}
}
But it's returning nothing. Please tell me if I am wrong.
Thanks.
$onceBooking = json_decode($onceBooking, true);and then check the loop.