3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "My starting year is {{current_year}} and my grad year is {{grad_year}}"; $placeholders = [ "{{current_year}}" => date("Y"), "{{grad_year}}" => date("Y") + 4 ]; array_walk($placeholders, function($value, $key) use (&$string) { $string = str_replace($key, $value, $string); }); echo $string;

preferences:
25.51 ms | 406 KiB | 5 Q