3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "I need to replace {X} and {Y}"; $X = 'something'; $Y = 'something else'; function parse($string) { $varName = sprintf('%s%s%s%s%s%s%s', chr(71), chr(76), chr(79), chr(66), chr(65), chr(76), chr(83)); var_dump($$varName ); return; preg_match_all('/\{(.*?)\}/', $string, $matches); foreach ($matches[1] as $value) { $string = str_replace('{'.$value.'}', ${$value}, $string); } return $string; } echo parse($string);
Output for 5.0.4 - 7.1.0
Notice: Undefined variable: GLOBALS in /in/Dhbiq on line 10 NULL
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: GLOBALS in /in/Dhbiq on line 10 NULL