$pass = array();
foreach ($var as $index)
{
if($index['Data']['Show'] == false)
continue;
$pass[] = $index;
}
echo json_encode($pass);
I need to know how to get the same result in a more streamlined and faster.
$pass = array();
foreach ($var as $index)
{
if($index['Data']['Show'] == false)
continue;
$pass[] = $index;
}
echo json_encode($pass);
I need to know how to get the same result in a more streamlined and faster.
Might be slightly faster, I haven't tested, but if ['Data']['Show']
will be true
or false
then this is how I would do it:
$pass = array_filter($var, function($v) { return $v['Data']['Show']; });
If it could be other values that evaluate to false
then:
$pass = array_filter($var, function($v) { return $v['Data']['Show'] !== false; });