Created
September 1, 2020 20:36
-
-
Save tcelestino/e90e5715d2d9e94f164f2abc14b3bb1e to your computer and use it in GitHub Desktop.
verify has array's children are empty
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
<?php | |
function isntEmpty($x) | |
{ | |
$key = array_keys($x)[0]; | |
if(!empty($x[$key])) { | |
return $x; | |
} | |
} | |
$t = [ | |
'id' => '', | |
'term' => '' | |
]; | |
$tt = [ | |
'id' => '', | |
'term' => '' | |
]; | |
$consent = [ | |
'item1' => $t, | |
'item2' => $tt | |
]; | |
$filteredData = array_filter($consent,"isntEmpty"); | |
print_r($filteredData); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment