3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $exists = 'ok'; $array = ['var' => 'var1', 'bar' => 'bar1', 'exists' => 'foo']; foreach ($array as $key => $value) { if (isset(${$key})) { ${'data_' . $key} = $value; } else { ${$key} = $value; } } var_dump($var, $bar, $exists, $data_exists);
based on 1vdQS
Output for 5.4.0 - 7.2.11
string(4) "var1" string(4) "bar1" string(2) "ok" string(3) "foo"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/fvemu on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/fvemu on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/fvemu on line 4
Process exited with code 255.