3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = "abcdefgh"; $ass_arr = array(); $ass_arr["foo"] = "bar"; $str = preg_replace_callback("/[aeiou]/", function($matches){ global $ass_arr; $ass_arr["bar"] = "baz"; return "x"; }, $str); var_dump($str); var_dump($ass_arr);
based on PLSad
Output for 5.5.0 - 7.3.0beta1
string(8) "xbcdxfgh" array(2) { ["foo"]=> string(3) "bar" ["bar"]=> string(3) "baz" }