3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pcre_stristr($raw,$str,$pos=false){ $r = ''; if($raw!='' && $str!=''){ $str = (string) $str; $tmp = preg_split('/'.preg_quote($str,'/').'/su',$raw,2,PREG_SPLIT_OFFSET_CAPTURE); if(count($tmp)==2){ if($pos){ $r = $tmp[0][0]; } else{ if($tmp[0][0]==''){ $r = $raw; } else{ $r = substr($raw,strlen($tmp[0][0])); } } } else{ $r = false; } } return $r; } $raw = '0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ'; $len = mb_strlen($raw); $tmp = array(); for($i=0;$i<10000;$i++){ $start = $lenth = 0; $start = mt_rand(0,$len-1); $length = mt_rand(1,min($len-$start,10)); if($start+$length<=$len){ $tmp[] = mb_substr($raw,$start,$length); } } $tmp = array_slice(array_unique($tmp),0,1000); echo '-----compatibility test-----'.PHP_EOL; echo 'samples count: '.count($tmp).PHP_EOL; foreach($tmp as $str){ $chk = true; if($chk && mb_strstr($raw,$str)!=pcre_stristr($raw,$str)){ $chk = false; } if($chk && mb_strstr($raw,$str,true)!=pcre_stristr($raw,$str,true)){ $chk = false; } if(!$chk && $str!='ß'){ echo 'raw: '.$raw.PHP_EOL; echo 'str: '.$str.PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,false)'.PHP_EOL.mb_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,false)'.PHP_EOL.pcre_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,true)'.PHP_EOL.mb_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,true)'.PHP_EOL.pcre_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'test failed'; exit(); } } echo 'test finished'.PHP_EOL.PHP_EOL; echo '-----runtime test-----'.PHP_EOL; echo 'mb_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ mb_strstr($raw,$str); } $timea = microtime(true)-$time; echo 'load in '.number_format($timea,5).'ms'.PHP_EOL.PHP_EOL; echo 'pcre_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ pcre_stristr($raw,$str); } $timeb = microtime(true)-$time; echo 'load in '.number_format($timeb,5).'ms'.PHP_EOL.PHP_EOL; echo 'time save '.number_format(100-100*($timeb/$timea),2).'%'; ?>

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.4.00.0030.04317.43
7.3.120.0100.03717.40
7.3.110.0070.05117.22
7.3.100.0100.03017.04
7.3.90.0060.03617.39
7.3.80.0100.03217.71
7.3.70.0070.03417.43
7.3.60.0070.03217.21
7.3.50.0030.04017.42
7.3.40.0100.03017.31
7.3.30.0030.04317.50
7.3.20.0060.02920.23
7.3.10.0040.03619.87
7.3.00.0100.03019.80
7.2.250.0130.05317.39
7.2.240.0070.05817.72
7.2.230.0030.03717.63
7.2.220.0000.05017.75
7.2.210.0070.03717.71
7.2.200.0030.03817.46
7.2.190.0100.03417.57
7.2.180.0100.03117.71
7.2.170.0070.03617.61
7.1.330.0070.04419.28
7.1.320.0030.04419.40
7.1.310.0070.04219.21
7.1.300.0000.04719.36
7.1.290.0130.04019.27
7.1.280.0100.04319.16
7.1.270.0030.04619.12
7.1.260.0000.04719.20
7.1.70.0070.03620.47
7.1.60.0100.06020.82
7.1.50.0070.04020.82
7.1.00.0030.12325.73
7.0.200.0140.04318.09
7.0.60.0030.07322.92
7.0.50.0030.07020.79
7.0.40.0070.11021.34
7.0.30.0270.09721.22
7.0.20.0270.06321.23
7.0.10.0100.12021.29
7.0.00.0170.12021.29
5.6.280.0000.08024.01
5.6.210.0030.12323.33
5.6.200.0030.07021.08
5.6.190.0100.07723.20
5.6.180.0370.07023.20
5.6.170.0330.11723.18
5.6.160.0100.10723.17
5.6.150.0070.13321.03
5.6.140.0100.12321.09
5.6.130.0130.12320.99
5.6.120.0070.07323.98
5.6.110.0070.13023.77
5.6.100.0070.13323.97
5.6.90.0130.07723.88
5.6.80.0100.12723.14
5.5.350.4270.05323.28
5.5.340.0170.08720.75
5.5.330.0070.05323.04
5.5.320.0000.06322.82
5.5.310.0300.07323.00
5.5.300.0100.04320.74
5.5.290.0100.05320.75
5.5.280.0070.07023.63
5.5.270.0130.07723.61
5.5.260.0130.09023.62
5.5.250.0200.08323.47
5.5.240.0230.08723.04
5.4.450.0330.05322.21
5.4.440.0330.05022.17
5.4.430.0330.05022.06
5.4.420.0330.05722.20
5.4.410.0470.04322.05
5.4.400.0530.07722.02
5.4.390.0500.08021.64
5.4.380.0500.06721.80
5.4.370.0600.05321.67
5.4.360.0470.09021.85
5.4.350.0570.07322.02
5.4.340.0630.06321.88
5.4.320.0300.05022.10
5.4.310.0300.05021.89
5.4.300.0270.07321.73
5.4.290.0430.06321.85
5.4.280.0530.06721.63
5.4.270.0470.06021.64
5.4.260.0600.05721.75
5.4.250.0530.08321.64
5.4.240.0470.08321.74
5.4.230.0500.04721.88
5.4.220.0430.09021.75
5.4.210.0370.07721.74
5.4.200.0500.07722.00
5.4.190.0500.08021.86
5.4.180.0230.09321.87
5.4.170.0400.08721.90
5.4.160.0530.08022.01
5.4.150.0430.07021.99
5.4.140.0470.04319.12
5.4.130.0470.06019.34
5.4.120.0370.05019.32
5.4.110.0600.07019.32
5.4.100.0330.05319.31
5.4.90.0430.04019.11
5.4.80.0670.04719.35
5.4.70.0400.08319.38
5.4.60.0400.06319.23
5.4.50.0530.08019.26
5.4.40.0370.04719.36
5.4.30.0370.05319.28
5.4.20.0430.04719.07
5.4.10.0400.04719.08
5.4.00.0370.04718.61
5.3.290.0330.08717.50
5.3.280.0470.07017.29
5.3.270.0230.07317.24
5.3.260.0470.09717.40
5.3.250.0430.08317.31
5.3.240.0530.08317.25
5.3.230.0500.09017.52
5.3.220.0300.06717.18
5.3.210.0430.09017.31
5.3.200.0400.06317.19
5.3.190.0470.06317.21
5.3.180.0500.08717.45
5.3.170.0470.08017.40
5.3.160.0430.06317.20
5.3.150.0400.08017.35
5.3.140.0500.08317.34
5.3.130.0500.07717.46
5.3.120.0400.05717.34
5.3.110.0370.05017.27
5.3.100.0400.08716.85
5.3.90.0470.07316.94
5.3.80.0470.09016.93
5.3.70.0270.07016.93
5.3.60.0500.08316.70
5.3.50.0330.06716.58
5.3.40.0470.08316.74
5.3.30.0270.06316.63
5.3.20.0370.09016.30
5.3.10.0130.04716.36
5.3.00.0270.04716.44
5.2.170.0270.08013.70
5.2.160.0300.07313.51
5.2.150.0330.06713.61
5.2.140.0300.05313.48
5.2.130.0270.05713.48
5.2.120.0030.05013.74
5.2.110.0200.07713.46
5.2.100.0370.04713.50
5.2.90.0300.07013.46
5.2.80.0200.04313.42
5.2.70.0230.07013.60
5.2.60.0370.06713.46
5.2.50.0300.07013.53
5.2.40.0330.07313.63
5.2.30.0200.04713.52
5.2.20.0170.05013.31
5.2.10.0270.04313.22
5.2.00.0500.03313.14
5.1.60.0200.04013.35
5.1.50.0300.06313.43
5.1.40.0230.08013.50
5.1.30.0230.08013.86
5.1.20.0200.07313.73
5.1.10.0170.04313.74
5.1.00.0270.07313.51
5.0.50.0130.04712.09
5.0.40.0130.04012.02
5.0.30.0100.05312.02
5.0.20.0170.04012.02
5.0.10.0200.06012.02
5.0.00.0430.04312.02
4.4.90.0070.04012.02
4.4.80.0130.05012.02
4.4.70.0130.03312.02
4.4.60.0170.04012.02
4.4.50.0070.05012.02
4.4.40.0070.05012.02
4.4.30.0070.05312.02
4.4.20.0130.03712.02
4.4.10.0100.04312.02
4.4.00.0100.05712.02
4.3.110.0130.05312.02
4.3.100.0070.03712.02
4.3.90.0130.05012.02
4.3.80.0130.08012.02
4.3.70.0130.06012.02
4.3.60.0130.04012.02
4.3.50.0130.05012.02
4.3.40.0100.05012.02
4.3.30.0100.04712.02
4.3.20.0100.08312.02
4.3.10.0070.13312.02
4.3.00.0030.10712.02

preferences:
44.17 ms | 401 KiB | 5 Q