Created
November 10, 2019 08:37
-
-
Save teomanofficial/ae1a8771f00617bc3c8860480793c62c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pullOut(array &$arr, ...$parameters) | |
{ | |
$result = []; | |
foreach ($parameters as $key => $parameter) { | |
$result[$key] = $arr[$parameter]; | |
unset($arr[$parameter]); | |
} | |
return $result; | |
} | |
function array_values_recursive(array $arr): array | |
{ | |
$arr = array_values($arr); | |
foreach ($arr as $key => $value) { | |
if (is_array($value)) { | |
$arr[$key] = array_values_recursive($value); | |
} | |
} | |
return $arr; | |
} | |
function array_list(array $array, &$total) | |
{ | |
if (is_null($total)) { | |
$total = []; | |
} | |
foreach ($array as $item) { | |
if (is_array($item)) { | |
array_list($item, $total); | |
} else { | |
array_push($total, $item); | |
} | |
} | |
} | |
function scandir_filtered($dir) | |
{ | |
if (!is_dir($dir)) { | |
throw new Exception("Directory Not Found"); | |
} | |
return array_diff(scandir($dir), [".", ".."]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment