run code in 200+ php & hhvm versions
Bugs & Features
<?php // Example array $array = array( 'hair' => 765, 'goblins' => null, 'ogres' => 'no ogres allowed in this array', 'harry' => '' ); // Loose checking var_dump(in_array(null, $array)); var_dump(in_array(false, $array)); var_dump(in_array(765, $array)); var_dump(in_array(763, $array)); var_dump(in_array('egg', $array)); var_dump(in_array('hhh', $array)); var_dump(in_array(array(), $array)); // Strict checking echo "now with strict\n"; var_dump(in_array(null, $array, true)); var_dump(in_array(false, $array, true)); var_dump(in_array(765, $array, true)); var_dump(in_array(763, $array, true)); var_dump(in_array('egg', $array, true)); var_dump(in_array('hhh', $array, true)); var_dump(in_array(array(), $array, true)); ?>
Output for 4.3.0 - 7.2.0
bool(true) bool(true) bool(true) bool(false) bool(false) bool(false) bool(true) now with strict bool(true) bool(false) bool(true) bool(false) bool(false) bool(false) bool(false)