Flatten Array in Php


November 12, 2018 2 minutes php , functions , flatten array

following code for int type in my case. just change function appropriately when you want to change

public function flattenUnique(array $array) {
  $return = array();
  array_walk_recursive($array, function($a) use (&$return) { $return[] = intval($a); });
  return array_unique( $return );
}

See Also