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;
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
My starting year is 2025 and my grad year is 2029

preferences:
40.18 ms | 406 KiB | 5 Q