3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function c_in_array($needle, $haystack){ if(!is_array($haystack)){ return false; } foreach($haystack as $index => $value){ var_dump($index, $value); if(is_array($value)){ return c_in_array($needle, $value); }else{ if($needle == $value){ return true; } } } return false; } $array = []; $array[] = ['content' => '192.168.178.1', 'disabled' => true]; $array[] = ['content' => '192.168.178.2', 'disabled' => false]; var_dump($array, c_in_array('192.168.178.4', $array)); //var_dump($array, array_search('192.168.178.2', $array));
based on sRNGb
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
int(0) array(2) { ["content"]=> string(13) "192.168.178.1" ["disabled"]=> bool(true) } string(7) "content" string(13) "192.168.178.1" string(8) "disabled" bool(true) array(2) { [0]=> array(2) { ["content"]=> string(13) "192.168.178.1" ["disabled"]=> bool(true) } [1]=> array(2) { ["content"]=> string(13) "192.168.178.2" ["disabled"]=> bool(false) } } bool(true)