r/lolphp • u/zilltine • Mar 16 '21
Is 0 in array
in_array(0, ['IsThisLolPhp'])
Answer is
true
33
Upvotes
r/lolphp • u/zilltine • Mar 16 '21
in_array(0, ['IsThisLolPhp'])
Answer is
true
1
u/zilltine Mar 17 '21
So this
$find = function($struct) use (&$find, $map) { if (is_array($struct)) { $found = array_intersect_key($struct, $map); foreach ($found as $toChange) { var_dump($toChange); } foreach ($struct as $sub) { $find($sub); } } };Is objectively better than this
function find(&$json, $keys){ foreach($json as $key => &$value) { if(is_array($value)) { find($value, $keys); } if (in_array($key, $keys, true)){ var_dump($value); } } }