in php remove keys and convert into a flat arrays -
, want remove key "holiday_date" , falt arry array('2010-01-01','2010-01-02',...) smarter way rather loop?
you need use array_column(),
$tmp = array_column($tmp, 'holiday_date'); this pull out 'holiday_date' values internal arrays, , storing them in $tmp itself, after line, $tmp formed need.
example: consider below array,
$records = array( array( 'id' => 2135, 'first_name' => 'john', 'last_name' => 'doe', ), array( 'id' => 3245, 'first_name' => 'sally', 'last_name' => 'smith', )); applying, array_column() below,
array_column($records, 'first_name'); will return,
array ( [0] => john [1] => sally ) if using php version < 5.5, refer this quick implementation of array_column().
Comments
Post a Comment