isset($b['room_id']) ? $b['room_id'] : null, 'roomtype_id' => isset($b['roomtype_id']) ? $b['roomtype_id'] : null, 'room_name' => isset($b['room_name']) ? $b['room_name'] : null, 'max_occupancy' => isset($b['max_occupancy']) ? $b['max_occupancy'] : null, 'nr_adults' => isset($b['nr_adults']) ? $b['nr_adults'] : null, 'nr_children' => isset($b['nr_children']) ? $b['nr_children'] : null, 'room_surface_in_m2' => isset($b['room_surface_in_m2']) ? $b['room_surface_in_m2'] : null, 'number_of_bedrooms' => isset($b['number_of_bedrooms']) ? $b['number_of_bedrooms'] : null, 'number_of_bathrooms' => isset($b['number_of_bathrooms']) ? $b['number_of_bathrooms'] : null, ), JSON_PRETTY_PRINT) . PHP_EOL . '---' . PHP_EOL; } } echo PHP_EOL . "=== ROOMS[] - BED CONFIGS + VIEW ===" . PHP_EOL; foreach ($rooms_data as $roomId => $roomVal) { $bedConfs = isset($roomVal['bed_configurations']) ? $roomVal['bed_configurations'] : array(); $highlights = isset($roomVal['highlights']) ? $roomVal['highlights'] : array(); $views = array(); foreach ($highlights as $h) { if (strpos(strtolower(isset($h['translated_name']) ? $h['translated_name'] : ''), 'view') !== false) { $views[] = $h['translated_name']; } } $beds = array(); foreach ($bedConfs as $conf) { foreach (isset($conf['bed_types']) ? $conf['bed_types'] : array() as $bt) { $beds[] = array( 'bed_type_id' => isset($bt['bed_type']) ? $bt['bed_type'] : null, 'name' => isset($bt['name']) ? $bt['name'] : null, 'count' => isset($bt['count']) ? $bt['count'] : null, ); } } echo json_encode(array( 'room_id' => $roomId, 'beds' => $beds, 'views' => $views, ), JSON_PRETTY_PRINT) . PHP_EOL . '---' . PHP_EOL; }