3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $subject = 'Aaaafaba Bbab'; $ret = preg_replace_callback_array( [ '~[a]+~i' => function ($match) { echo strlen($match[0]), ' matches for "a" found', PHP_EOL; }, '~[b]+~i' => function ($match) { echo strlen($match[0]), ' matches for "b" found', PHP_EOL; } ], $subject ); var_dump($ret); var_dump($subject);
Output for 7.0.0 - 7.2.0
4 matches for "a" found 1 matches for "a" found 1 matches for "a" found 1 matches for "a" found 1 matches for "b" found 3 matches for "b" found string(2) "f " string(13) "Aaaafaba Bbab"
Output for 5.4.2 - 5.6.28
Fatal error: Call to undefined function preg_replace_callback_array() in /in/2HW3o on line 5
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/2HW3o on line 6
Process exited with code 255.