getData(); // check whether the first element of the array is another array if (is_array(reset($data->flag_char))) { $tmp = []; // convert a multi-dimension array into a linear list of bookings foreach ($data->flag_char as $date => $map) { // register the keys (booking IDs) within the new array $tmp = array_merge($tmp, array_keys($map)); } // overwrite previous cache with the new one (get rid of duplicates) $data->flag_char = array_unique($tmp); } } }