3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'Showing results [program=for {program} programs|No pogram at all] [province=in {province}] [degree=with degree of {degree}]'; function interpolateString($message, array $context = array()) { $replace = array(); foreach ($context as $key => $val) { $replace['{' . $key . '}'] = $val; } return strtr($message, $replace); } $arrContext = array( 'program' => 'Nursing', 'province' => 'Ontario', 'degree' => '0' ); echo interpolateString($str, $arrContext); $pattern = '/\[\w+\=(.*)?\|(.*)\]'; $replacement = '_'; $subject = $str; echo preg_replace($pattern, $replacement, $subject);
Output for git.master, git.master_jit, rfc.property-hooks
Showing results [program=for Nursing programs|No pogram at all] [province=in Ontario] [degree=with degree of 0] Warning: preg_replace(): No ending delimiter '/' found in /in/5KJKd on line 22

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