@ 2018-06-03T21:52:26Z <?php
$array = [
'a' => 'a',
'b' => '',
'c' => null,
'd' => 122,
'e' => 0,
'f' => [
'g' => 'g',
'h' => 0,
'i' => null,
'j' => ''
]
];
$result = array_filter($array, function ($arr) {
if (!is_array($arr)) {
return strlen($arr) ;
}
return array_filter($arr) ;
} ) ;
$r = array_filter($array) ;
var_dump($r);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /in/Rb7Da on line 19
array(3) {
["a"]=>
string(1) "a"
["d"]=>
int(122)
["f"]=>
array(4) {
["g"]=>
string(1) "g"
["h"]=>
int(0)
["i"]=>
NULL
["j"]=>
string(0) ""
}
}
Output for 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 array(3) {
["a"]=>
string(1) "a"
["d"]=>
int(122)
["f"]=>
array(4) {
["g"]=>
string(1) "g"
["h"]=>
int(0)
["i"]=>
NULL
["j"]=>
string(0) ""
}
}
preferences:dark mode live preview
183.99 ms | 406 KiB | 169 Q