3v4l.org

run code in 300+ PHP versions simultaneously
<?php $js_date = "12.12.2013"; $js_time = "10.00"; public function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) { // Link attributes $attr = 'http://www.abctehno.ee'; foreach ($attributes as $key => $val) { $attr = ' ' . $key . '="' . htmlentities($val) . '"'; } $links = array(); // Extract existing links and tags $value = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function ($match) use (&$links) { return '<' . array_push($links, $match[1]) . '>'; }, $value); // Extract text links for each protocol foreach ((array)$protocols as $protocol) { switch ($protocol) { case 'http': case 'https': $value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { if ($match[1]) $protocol = $match[1]; $link = $match[2] ?: $match[3]; return '<' . array_push($links, "<a $attr href=\"$protocol://$link\">$link</a>") . '>'; }, $value); break; case 'mail': $value = preg_replace_callback('~([^\s<]+?@[^\s<]+?\.[^\s<]+)(?<![\.,:])~', function ($match) use (&$links, $attr) { return '<' . array_push($links, "<a $attr href=\"mailto:{$match[1]}\">{$match[1]}</a>") . '>'; }, $value); break; case 'twitter': $value = preg_replace_callback('~(?<!\w)[@#](\w++)~', function ($match) use (&$links, $attr) { return '<' . array_push($links, "<a $attr href=\"https://twitter.com/" . ($match[0][0] == '@' ? '' : 'search/%23') . $match[1] . "\">{$match[0]}</a>") . '>'; }, $value); break; default: $value = preg_replace_callback('~' . preg_quote($protocol, '~') . '://([^\s<]+?)(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { return '<' . array_push($links, "<a $attr href=\"$protocol://{$match[1]}\">{$match[1]}</a>") . '>'; }, $value); break; } } // Insert all link return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) { return $links[$match[1] - 1]; }, $value); } $email_message ="\n Lugupeetud klient, \n \n teile broneeritud ülevaatuse aeg on ".$js_date." kell ".$js_time.". ABC Tehno asub aadressil Sõpruse pst 27, tel: 6 999 227, email: info@abctehno.ee, koduleht: ".$page. ".\n Tuletame meelde, et hilinemisel kaotab broneering kehtivuse. \n \n Kohtumiseni, \n ABC Tehno"; echo $email_message; ?>

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.220.0130.03912.37
5.4.210.0090.04312.37
5.4.200.0110.05812.37
5.4.190.0090.05512.36
5.4.180.0140.05312.36
5.4.170.0120.04712.37
5.4.160.0130.04312.36
5.4.150.0110.04712.36
5.4.140.0100.05012.05
5.4.130.0110.05112.03
5.4.120.0130.04412.00
5.4.110.0100.05111.99
5.4.100.0100.04712.00
5.4.90.0080.04812.00
5.4.80.0130.04111.99
5.4.70.0140.04211.99
5.4.60.0110.04312.00
5.4.50.0110.04311.99
5.4.40.0110.05911.98
5.4.30.0120.04411.98
5.4.20.0130.04911.97
5.4.10.0130.04311.98
5.4.00.0110.04611.47
5.3.270.0110.04712.72
5.3.260.0130.04512.72
5.3.250.0130.04412.72
5.3.240.0120.04712.72
5.3.230.0110.04712.71
5.3.220.0140.04712.68
5.3.210.0120.04312.68
5.3.200.0140.04112.68
5.3.190.0110.05112.68
5.3.180.0130.04612.67
5.3.170.0130.04612.67
5.3.160.0100.04312.67
5.3.150.0130.04312.67
5.3.140.0150.04112.66
5.3.130.0120.04812.66
5.3.120.0120.04712.66
5.3.110.0100.04512.66
5.3.100.0110.04612.12
5.3.90.0140.04312.08
5.3.80.0130.04512.07
5.3.70.0110.04412.07
5.3.60.0130.04812.07
5.3.50.0120.04612.00
5.3.40.0130.04812.00
5.3.30.0170.05911.94
5.3.20.0110.06011.71
5.3.10.0140.04611.67
5.3.00.0110.04511.66

preferences:
141.55 ms | 1394 KiB | 7 Q