Skip to content

Instantly share code, notes, and snippets.

@pzzrudlf
Created December 10, 2015 03:04
Show Gist options
  • Select an option

  • Save pzzrudlf/822cef7f82d09ce1fcbb to your computer and use it in GitHub Desktop.

Select an option

Save pzzrudlf/822cef7f82d09ce1fcbb to your computer and use it in GitHub Desktop.
/**
* recursive function in order to convert a multiple dimensions array to a single dimension array
* @param array $array
* @param array $res
* @return $res
* @auther pzzrudlf <pzzrudlf@gmail.com>
*/
public function convertToSingleArray($array, &$res=[])
{
foreach ($array as $key => $value) {
array_push($res,$key);
self::convertToSingleArray($value, $res);
}
return $res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment