3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replaceValues(array $kvPairs, string $text): string { return preg_replace_callback( '/{{\s*(.*?)\s*}}/', fn($m) => isset($kvPairs[strtolower($m[1])]) ? '<span class="attr">' . $kvPairs[strtolower($m[1])] . '</span>' : '<span class="attrUnknown">' . $m[1] . '</span>', $text ); } $translations = [ 'date' => '1977-05-20', 'time' => '01:02:03', 'bar' => 'Fighters', ]; echo replaceValues($translations, "Your tickets to the Foo {{ Bar}} were purchased @ {{dAte }} {{ tiME }}");
Output for git.master, git.master_jit, rfc.property-hooks
Your tickets to the Foo <span class="attr">Fighters</span> were purchased @ <span class="attr">1977-05-20</span> <span class="attr">01:02:03</span>

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:
61.55 ms | 405 KiB | 5 Q