I have an array built like this
array (size=2) 0 => array (size=12) 'id_objects' => string '2876' (length=4) 'room_val' => string '1882840,1882841,1882842' (length=23) 'date_from' => string '2022-06-22' (length=10) 'date_to' => string '2022-06-22' (length=10) 1 => array (size=12) 'id_objects' => string '2876' (length=4) 'room_val' => string '3198723,3198724,3198726' (length=23) 'date_from' => string '2022-06-22' (length=10) 'date_to' => string '2022-06-22' (length=10)
What I need to achieve is, explode 'room_val' but keep the rest of the data the same, it needs to look like this
array (size=2) 0 => array (size=12) 'id_objects' => string '2876' (length=4) 'room_val' => string '1882840' (length=23) 'date_from' => string '2022-06-22' (length=10) 'date_to' => string '2022-06-22' (length=10) 1 => array (size=12) 'id_objects' => string '2876' (length=4) 'room_val' => string '1882841' (length=23) 'date_from' => string '2022-06-22' (length=10) 'date_to' => string '2022-06-22' (length=10) ..... rest of array
is it possible?
You need to parse the array of arrays and create a new array that matches what you are looking for.
Similar to: