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' => false ); //echo interpolateString($str, $arrContext); echo "\n"; $arrMatches = array(); preg_match_all("/\[(\w+)\=([^\[\]\|.*]*)?\|*([^\[\].*]*)\]/", $str, $arrMatches); for ($i=0; $i<=count($arrMatches[1])-1;$i++) { if ($arrContext[$arrMatches[1][$i]] !== false) { $str = strstr($arrMatches[0][$i], $arrMatches[2][$i] }else{ $str = strstr($arrMatches[0][$i], $arrMatches[2][$i]; } } echo $str;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.150.0230.07112.37
5.4.140.0170.04512.06
5.4.130.0220.05512.04
5.4.120.0170.04312.01
5.4.110.0160.04312.01
5.4.100.0230.05312.01
5.4.90.0180.04412.01
5.4.80.0290.06112.01
5.4.70.0160.04412.00
5.4.60.0160.04312.00
5.4.50.0160.04112.00
5.4.40.0190.03811.99
5.4.30.0190.04111.98
5.4.20.0160.04311.98
5.4.10.0300.05811.98
5.4.00.0180.04111.48
5.3.250.0080.04012.72
5.3.240.0150.04912.72
5.3.230.0170.04512.71
5.3.220.0140.04512.68
5.3.210.0210.06912.68
5.3.200.0170.04312.68
5.3.190.0380.07112.67
5.3.180.0140.04612.67
5.3.170.0170.04312.67
5.3.160.0140.04612.67
5.3.150.0140.04612.67
5.3.140.0210.05712.66
5.3.130.0140.04912.66
5.3.120.0170.04512.65
5.3.110.0280.06412.66
5.3.100.0160.04512.12
5.3.90.0270.06512.09
5.3.80.0130.04912.08
5.3.70.0190.04312.08
5.3.60.0270.08212.07
5.3.50.0200.04612.01
5.3.40.0160.04312.01
5.3.30.0170.04311.97
5.3.20.0150.04311.75
5.3.10.0130.04311.71
5.3.00.0160.04311.70

preferences:
137.91 ms | 1394 KiB | 7 Q