3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array('key', 'value', 'key2'); $iterations = count($arr); $result = array(); for ($i = 0; $i < $iterations; $i += 2) $result[$arr[$i]] = isset($arr[$i + 1]) ? $arr[$i + 1] : null; var_dump($result);
Output for 4.3.0 - 5.6.22, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { ["key"]=> string(5) "value" ["key2"]=> NULL }