3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_internal_encoding('UTF-8'); $full_string = 'ĂȘtre vivant'; $match = 'vivant'; //) is ĂȘtr<strong>e viva</strong>nt echo Foo::highlightTerm($full_string, $match); class Foo{ public static function highlightTerm($full_string, $match){ $full_string_ascii = preg_replace_callback('/[\w]+/ui', array('self', 'callbackHighlightTerm'), $full_string); $match_ascii = preg_replace_callback('/[\w]+/ui', array('self', 'callbackHighlightTerm'), $match); $start = stripos($full_string_ascii, $match_ascii); if($start===FALSE){ return $full_string; }else{ $length = mb_strlen($match); return htmlspecialchars( mb_substr($full_string, 0, $start)) . '<strong>' . htmlspecialchars( mb_substr($full_string, $start, $length) ) . '</strong>' . htmlspecialchars( mb_substr($full_string, $start+$length) ); } } private static function callbackHighlightTerm($matches){ /**/var_dump(preg_replace('/[^\w]/i', '', iconv('UTF-8', 'ASCII//TRANSLIT', $matches[0])); return preg_replace('/[^\w]/i', '', iconv('UTF-8', 'ASCII//TRANSLIT', $matches[0])); } } ?>

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.140.0070.04716.41
5.4.130.0030.04016.41
5.4.120.0100.04016.26
5.4.110.0030.06316.43
5.4.100.0070.07316.53
5.4.90.0100.07016.43
5.4.80.0070.07316.27
5.4.70.0030.05016.32
5.4.60.0030.03716.43
5.4.50.0100.07016.40
5.4.40.0070.04316.36
5.4.30.0030.03716.30
5.4.20.0100.07016.52
5.4.10.0070.07316.37
5.4.00.0000.04015.82
5.3.240.0030.05714.50
5.3.230.0000.04314.53
5.3.220.0170.03314.61
5.3.210.0070.08014.59
5.3.200.0070.05014.57
5.3.190.0070.03714.58
5.3.180.0200.06714.63
5.3.170.0130.06714.73
5.3.160.0000.04314.62
5.3.150.0100.07714.61
5.3.140.0130.05314.59
5.3.130.0070.04014.57
5.3.120.0100.07014.48
5.3.110.0070.07714.59
5.3.100.0070.07714.08
5.3.90.0030.06714.06
5.3.80.0030.06014.10
5.3.70.0070.06714.08
5.3.60.0100.05314.01
5.3.50.0100.07313.84
5.3.40.0030.06313.95
5.3.30.0030.04314.08
5.3.20.0100.07713.70
5.3.10.0070.05313.68
5.3.00.0130.04713.65

preferences:
139.22 ms | 1394 KiB | 7 Q