3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $numeric_fails = 0; $non_numeric_fails = 0; $iterations = 1000; $results = array( 'Numeric Equal' => NULL, 'Non-numeric Equal' => NULL, 'Numeric Fail' => NULL, 'Non-numeric Fail' => NULL ); for ($i = 0; $i < $iterations; $i++) { $my_key = uniqid("\x00"); $var = array(); $var[$my_key] = TRUE; foreach ($var as $key => $val) { if ($key === $my_key) { if (is_numeric($my_key)) { $results['Numeric Equal'] = TRUE; } else { $results['Non-numeric Equal'] = TRUE; } } else { if (is_numeric($my_key)) { $results['Numeric Fail'] = TRUE; } else { $results['Non-numeric Fail'] = TRUE; } } } } var_dump($results);
based on jtX6P
Output for 4.3.0 - 5.5.28, 5.5.30 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { ["Numeric Equal"]=> NULL ["Non-numeric Equal"]=> bool(true) ["Numeric Fail"]=> NULL ["Non-numeric Fail"]=> NULL }
Output for 5.5.29
array(4) { ["Numeric Equal"]=> bool(true) ["Non-numeric Equal"]=> bool(true) ["Numeric Fail"]=> bool(true) ["Non-numeric Fail"]=> NULL }