3v4l.org

run code in 300+ PHP versions simultaneously
<?php function c_in_array($needle, $haystack){ if(!is_array($haystack)){ return false; } foreach($haystack as $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));
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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)

preferences:
186.4 ms | 402 KiB | 218 Q