3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = json_decode('[ {"title":"Title #1", "text":"Text #1"}, {"title":"Title #2", "text":"Text #2"} ]'); $itemTmpl = "<h3 class='foo'>{title}</h3><div class='bar'>{text}</div>"; $html = []; foreach ($items as $item) { $html[] = preg_replace_callback( '/{([a-z]+)}/', fn($m) => $item->{$m[1]}, $itemTmpl ); } var_export($html);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => '<h3 class=\'foo\'>Title #1</h3><div class=\'bar\'>Text #1</div>', 1 => '<h3 class=\'foo\'>Title #2</h3><div class=\'bar\'>Text #2</div>', )

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:
45.07 ms | 401 KiB | 8 Q