Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Created September 1, 2020 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcelestino/e90e5715d2d9e94f164f2abc14b3bb1e to your computer and use it in GitHub Desktop.
Save tcelestino/e90e5715d2d9e94f164f2abc14b3bb1e to your computer and use it in GitHub Desktop.
verify has array's children are empty
<?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