Last active
February 17, 2018 09:45
-
-
Save 2ik/45ab356972b0d3c6c36ea1c432d8b763 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 array_clean($array) { | |
if(!is_array($array)) return; | |
foreach($array as $key => $value) { | |
if(!is_array($value)){ | |
$array[$key] = trim($value); | |
if(strlen($value)==0) | |
unset($array[$key]); | |
} | |
else | |
$array[$key] = array_clean($value); | |
} | |
return array_values($array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment