3v4l.org

run code in 300+ PHP versions simultaneously
<?php function updateYear(string $text, int $newYear): string { $year = null; $result = preg_replace_callback( '/(\-)(\d\d\d\d)/', function (array $matches) use ($newYear, &$year): string { $year = (int) $matches[2]; return $matches[1] . (string) $newYear; }, $text ); return "Replaced {$year} in '{$text} => '{$result}'"; } echo updateYear('(c) 1970-2022', 2023) . PHP_EOL; echo updateYear('(c) 1999-2022', 2023) . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Replaced 2022 in '(c) 1970-2022 => '(c) 1970-2023' Replaced 2022 in '(c) 1999-2022 => '(c) 1999-2023'

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.08 ms | 405 KiB | 5 Q