3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $numeric_fails = 0; $non_numeric_fails = 0; $iterations = 1000; $results = array(); 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 rIr0m
Output for 4.3.0 - 5.4.45, 5.5.25 - 5.6.12, 5.6.14 - 7.0.3, 7.0.5 - 7.1.0
array(1) { ["Non-numeric Equal"]=> bool(true) }
Output for 7.0.4
array(2) { ["Non-numeric Equal"]=> bool(true) ["Numeric Equal"]=> bool(true) }
Output for 5.6.13
array(3) { ["Non-numeric Equal"]=> bool(true) ["Numeric Equal"]=> bool(true) ["Numeric Fail"]=> bool(true) }
Output for 5.5.24
array(2) { ["Numeric Equal"]=> bool(true) ["Non-numeric Equal"]=> bool(true) }