3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "My starting year is {{current_year}} and my grad year is {{grad_year}}"; array_walk([ // List of placeholders and their values "{{current_year}}" => date("Y"), "{{grad_year}}" => date("Y") + 4 ], function($value, $key) use (&$string) { $string = str_replace($key, $value, $string); }); echo $string;
Output for 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Fatal error: Uncaught Error: array_walk(): Argument #1 ($array) could not be passed by reference in /in/sN0H4:6 Stack trace: #0 {main} thrown in /in/sN0H4 on line 6
Process exited with code 255.
Output for 8.2.0 - 8.2.27
Fatal error: Uncaught Error: array_walk(): Argument #1 ($array) cannot be passed by reference in /in/sN0H4:6 Stack trace: #0 {main} thrown in /in/sN0H4 on line 6
Process exited with code 255.

preferences:
43.75 ms | 407 KiB | 5 Q