for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sergiors\Functional;
const flatten = '\Sergiors\Functional\flatten';
/**
* @author Sérgio Rafael Siqueira <[email protected]>
*
* @param array $xs
* @return mixed
*/
function flatten(array $xs)
{
return array_reduce($xs, function ($carry, $x) {
if (is_array($x)) {
return array_merge($carry, flatten($x));
}
return array_merge($carry, [$x]);
}, []);