3v4l.org

run code in 300+ PHP versions simultaneously
<?php public function perfectStr($str,$length=12,$suffix=true,$charset="utf-8") { $start = 0; if(function_exists("mb_substr")) { if(mb_strlen($str, $charset) <= $length) return $str; $slice = mb_substr($str, $start, $length, $charset); } else { $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; preg_match_all($re[$charset], $str, $match); if(count($match[0]) <= $length) return $str; $slice = join("",array_slice($match[0], $start, $length)); } if($suffix) return $slice."…"; return $slice; } $a = '<p> <strong>◆ </strong>马特·波莫 (Matt Bomer) 因在电视剧《妙警贼探》中出色地饰演Neal Caffrey一角而为报友们所喜爱,尽显英伦范的着装风格和无可挑剔的好身材也让他获得粉丝的青睐无数,这位胡渣优质男卖起萌来毫不含糊,被报友粉丝亲昵地称为“孔雀”。让直女扼腕、腐女窃喜的是,马特·波莫 (Matt Bomer) 已经公开出柜,在2012年出席美国的史帝夫人权奖 (Steve Chase Humanitarian Awards) 颁奖典礼上,“孔雀”在发表获奖感言时大方向自己的伴侣Simon Halls表达感激之情,首度公开了自己的同性性取向。 </p> <p> <br /> 马特·波莫 (Matt Bomer) 1977年出生于美国德克萨斯的Spring市,父亲John Bomer是前达拉斯牛仔队 (Dallas Cowboys) 队员。马特·波莫 (Matt Bomer) 毕业于宾夕法尼亚州匹兹堡的卡内基梅隆大学,获艺术学士学位。毕业之后搬到纽约,继续在戏院舞台上演出,同时也积极争取在大荧幕上露面的机会,其出演的电视剧集包括《超市特工》、《亡命天涯》和早期的《指路明灯》等,还有2005年的电影《空中危机》和2011年的《钟点战》。2012年,马特·波莫 (Matt Bomer) 加盟影片《魔力麦克》(Magic Mik) ,片中他扮演一家脱衣舞男俱乐部的老板,出色的表演再度引起影迷的关注。 </p>'; $b = '<p> <strong>◆ </strong>英国演员史蒂芬·莫耶 (Stephen Moyer) 因为饰演HBO重口味美剧《真爱如血》(True Blood) 中的吸血鬼比尔·康普顿 (Bill Compton) 一角而被众多美剧迷所熟知。从小对表演有着浓厚兴趣的Stephen Moyer为了成为一名专业演员,进入了伦敦音乐学院的戏剧艺术系,并在那之后参演了很多戏剧。除了电视剧和戏剧,Stephen Moyer曾和多位巨星合作过,包括《鹅毛笔》(Quills) 中的凯特·温丝莱特 (Kate Winslet)、在《侠盗公主》(Princess of Thieves) 中的凯拉·奈特利 (Keira Knightley)、《88分钟》(88 Minutes) 中和阿尔·帕西诺 (Al Pacino) 等。参演《真爱如血》不仅让Stephen Moyer在事业上达到了一个巅峰,还给他的爱情生活带来了极大的变化。2010年8月,Stephen Moyer与《真爱如血》女主角苏琪 (Sookie) 的饰演者安娜·帕奎因 (Anna Paquin) 结婚,两人现在已经有了一对双胞胎儿子。 </p> <p> <br /> </p> <p> <strong>◆ 史蒂芬·莫耶 (Stephen Moyer ) 作品:</strong><br /> </p> <p> <strong><br /> </strong> </p>'; echo perfectStr(strip_tags($a),125); echo "\n\r"; echo perfectStr(strip_tags($b),125);

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.350.0090.05612.01
5.4.340.0130.05312.01
5.4.320.0060.04312.50
5.4.310.0050.05112.50
5.4.300.0110.07112.50
5.4.290.0290.09712.49
5.4.280.0080.05012.39
5.4.270.0150.07012.39
5.4.260.0060.05112.39
5.4.250.0130.05112.39
5.4.240.0090.05012.39
5.4.230.0090.05212.38
5.4.220.0080.05012.38
5.4.210.0080.06512.38
5.4.200.0060.04812.38
5.4.190.0080.04412.38
5.4.180.0100.05012.38
5.4.170.0090.04712.39
5.4.160.0090.04612.38
5.4.150.0130.03912.38
5.4.140.0100.06512.07
5.4.130.0070.04912.05
5.4.120.0120.05712.02
5.4.110.0220.08012.01
5.4.100.0180.08212.01
5.4.90.0080.04312.01
5.4.80.0100.04112.01
5.4.70.0100.03812.00
5.4.60.0070.04312.00
5.4.50.0070.04312.00
5.4.40.0050.04112.00
5.4.30.0080.04611.99
5.4.20.0050.04011.99
5.4.10.0240.07511.99
5.4.00.0160.06411.48
5.3.290.0130.05812.80
5.3.280.0270.09012.71
5.3.270.0090.06112.73
5.3.260.0080.05912.72
5.3.250.0230.10312.72
5.3.240.0060.05312.72
5.3.230.0080.05112.71
5.3.220.0120.04912.68
5.3.210.0070.05212.68
5.3.200.0090.05412.68
5.3.190.0120.04712.67
5.3.180.0070.04212.67
5.3.170.0090.03812.66
5.3.160.0140.05412.68
5.3.150.0070.04612.67
5.3.140.0140.06512.66
5.3.130.0180.06512.65
5.3.120.0080.06712.66
5.3.110.0130.06212.66
5.3.100.0160.07912.12
5.3.90.0080.05512.08
5.3.80.0110.06112.07
5.3.70.0050.04512.07
5.3.60.0270.09812.07
5.3.50.0060.04312.00
5.3.40.0140.04712.00
5.3.30.0260.06411.95
5.3.20.0100.05411.73
5.3.10.0220.09111.70
5.3.00.0110.08211.68
5.2.170.0080.0449.19
5.2.160.0070.0389.18
5.2.150.0050.0449.18
5.2.140.0110.0349.18
5.2.130.0050.0369.14
5.2.120.0090.0479.14
5.2.110.0120.0579.15
5.2.100.0060.0549.14
5.2.90.0090.0359.15
5.2.80.0110.0509.14
5.2.70.0080.0389.14
5.2.60.0160.0529.09
5.2.50.0120.0479.05
5.2.40.0040.0369.04
5.2.30.0050.0369.02
5.2.20.0070.0419.01
5.2.10.0060.0318.93
5.2.00.0140.0468.79
5.1.60.0080.0338.07
5.1.50.0050.0308.07
5.1.40.0090.0248.05
5.1.30.0110.0498.40
5.1.20.0040.0328.42
5.1.10.0080.0298.14
5.1.00.0080.0328.14
5.0.50.0060.0326.63
5.0.40.0080.0286.48
5.0.30.0060.0456.29
5.0.20.0100.0436.27
5.0.10.0040.0396.24
5.0.00.0030.0436.23
4.4.90.0040.0214.78
4.4.80.0100.0334.76
4.4.70.0020.0194.75
4.4.60.0040.0174.75
4.4.50.0040.0194.77
4.4.40.0070.0274.71
4.4.30.0060.0194.76
4.4.20.0050.0204.84
4.4.10.0020.0184.85
4.4.00.0090.0384.76
4.3.110.0050.0334.67
4.3.100.0050.0264.66
4.3.90.0040.0174.63
4.3.80.0040.0294.58
4.3.70.0230.0594.63
4.3.60.0050.0174.63
4.3.50.0040.0384.63
4.3.40.0070.0554.54
4.3.30.0040.0403.29
4.3.20.0130.0353.26
4.3.10.0150.0243.22
4.3.00.0200.0206.76

preferences:
150.54 ms | 1394 KiB | 7 Q