3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highlight($text, $words) { preg_match_all ( '~[a-zA-Z_']+~', $words, $m ); if (! $m) return $text; $re = '~\\b(' . implode ( '|', $m [0] ) . ')\\b~i'; return preg_replace ( $re, '<em>$0</em>', $text ); } $text = "this is Mechanic's test"; $word = "Mechanic's"; echo highlight($text,$word); $text = 'this is Mechanic"s test'; $word = 'Mechanic"s'; echo "\n".highlight($text,$word); $text = 'this is Mechanics test'; $word = 'mech'; echo "\n".highlight($text,$word); // echo "\n".str_replace($word,"<em>$word</em>",$text) ;

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)
7.1.70.0040.00816.61
7.1.60.0130.01334.89
7.1.50.0130.01334.50
7.1.40.0160.01034.19
7.1.30.0180.00734.18
7.1.20.0170.01034.49
7.1.10.0110.00416.20
7.1.00.0000.01216.32
7.0.200.0040.00816.46
7.0.190.0030.00916.19
7.0.180.0030.00915.79
7.0.170.0090.00316.15
7.0.160.0030.01015.93
7.0.150.0030.00916.07
7.0.140.0080.00416.01
7.0.130.0000.01216.32
7.0.120.0090.00316.23
7.0.110.0040.00716.05
7.0.100.0000.01116.26
7.0.90.0000.01216.12
7.0.80.0030.00916.22
7.0.70.0080.00616.03
7.0.60.0000.01316.02
7.0.50.0040.00816.28
7.0.40.0000.01116.23
7.0.30.0040.00716.18
7.0.20.0000.01716.23
7.0.10.0090.00616.31
7.0.00.0030.00916.20

preferences:
141.65 ms | 1394 KiB | 7 Q