Sometimes, for compatible in activerecord on a lot of php framework, we have an array then create a temporary array for suitable it.
So, more elegant if we don't need to make a temporary array. My favourite is array_map. What if an array like this :
Array
(
[0] => Array
(
[0] => 2017-05-19
[1] => HEUNG-A_HCHIMINH_0010S
)
[1] => Array
(
[0] => 2017-05-19
[1] => KITI_BHUM
)
)
Into
Array
(
[0] => Array
(
[date] => 2017-04-15
[vessel] => KMTC_HOCHIMINH
)
[1] => Array
(
[date] => 2017-04-15
[vessel] => OCL_NAGOYA
)
)
I need to use array_map.
Please advise.