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;

preferences:
24.35 ms | 406 KiB | 5 Q