3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $numeric_fails = 0; $non_numeric_fails = 0; $iterations = 5000; $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 BlQ0d
Output for 4.3.0 - 5.4.45, 5.5.25 - 5.5.28, 5.5.30 - 5.5.34, 5.6.7 - 5.6.11, 5.6.13 - 5.6.17, 5.6.19 - 5.6.20, 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.24, 5.5.29, 5.5.35, 5.6.12, 5.6.21
array(4) { ["Numeric Equal"]=> bool(true) ["Non-numeric Equal"]=> bool(true) ["Numeric Fail"]=> bool(true) ["Non-numeric Fail"]=> NULL }
Output for 5.6.18
array(4) { ["Numeric Equal"]=> bool(true) ["Non-numeric Equal"]=> bool(true) ["Numeric Fail"]=> NULL ["Non-numeric Fail"]=> NULL }