3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_search($string,$quote='"') { $terms = array(); $accept = array('"','\''); if( !is_string($string) || !is_string($quote) || strlen($quote) > 1 || !in_array($quote,$accept) ) { return false; } // matches all manner of whitespace $whitespace = '/\s+/'; // what to change escaped quotes to, i.e. \' or \" $escq = '%escq%'; // ways that spaces may be encoded $encoded = array('+'); // we'll be using it a lot $space = ' '; // turn URL encoded spaces into normal ones $str = str_replace($encoded,$space,stripslashes(html_entity_decode(urldecode($string)))); // replace multiple/odd whitespace characters with single spaces $str = trim(preg_replace($whitespace,$space,$str)); // allow the user to escape quotes with backslash $str = str_replace('\\'.$quote,$escq,$str); // get the number of quotes $count = substr_count($str,$quote); // if no matching quotes, just split it if($count < 2) { return explode($space,$str); } // as long as there is a matching pair of quotes while($count > 1) { $before = strpos($str,$quote); $start = $before + 1; $end = strpos($str,$quote,$start); $after = $end + 1; $length = $end - $start; // everything before the quote $beforeStr = rtrim(substr($str,0,$before)); // break it apart, add to the terms list $terms = array_merge($terms,explode($space,$beforeStr)); // add the quote as a phrase $terms[] = trim(substr($str,$start,$length)); // trim off everything up to and including the closing quote $str = trim(substr($str,$after)); $count = substr_count($str,$quote); } // no matching quotes left, just split and add what's left $terms = array_merge($terms,explode($space,$str)); // unescape the escaped quotes foreach($terms as &$term) { $term = str_replace($escq,$quote,$term); } // remove empty entries return array_filter($terms); } $parsed = parse_search('"Cityscape"');

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)
8.3.60.0140.00418.68
8.3.50.0120.00616.52
8.3.40.0090.00618.92
8.3.30.0100.01018.96
8.3.20.0040.00422.09
8.3.10.0050.00221.73
8.3.00.0080.00019.58
8.2.180.0090.00617.00
8.2.170.0110.00422.96
8.2.160.0090.01220.47
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0050.00326.16
8.2.120.0060.00317.75
8.2.110.0060.00319.27
8.2.100.0000.01417.75
8.2.90.0030.00619.25
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0000.01119.43
8.2.30.0000.00720.73
8.2.20.0000.00817.85
8.2.10.0000.00818.18
8.2.00.0040.00418.21
8.1.280.0030.01325.92
8.1.270.0060.01222.11
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0110.00021.12
8.1.230.0100.00320.29
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0030.00617.48
8.1.190.0090.00017.36
8.1.180.0040.00418.10
8.1.170.0040.00418.71
8.1.160.0000.00722.06
8.1.150.0040.00418.84
8.1.140.0090.00017.50
8.1.130.0050.00317.74
8.1.120.0050.00217.61
8.1.110.0040.00417.56
8.1.100.0040.00417.61
8.1.90.0070.00017.54
8.1.80.0070.00017.53
8.1.70.0030.00317.66
8.1.60.0080.00017.63
8.1.50.0000.00717.59
8.1.40.0030.00517.73
8.1.30.0000.00817.79
8.1.20.0000.00717.66
8.1.10.0000.00817.72
8.1.00.0000.00817.56
8.0.300.0050.00218.77
8.0.290.0040.00416.88
8.0.280.0000.00818.47
8.0.270.0040.00417.30
8.0.260.0030.00318.43
8.0.250.0000.00817.21
8.0.240.0000.00717.02
8.0.230.0080.00017.09
8.0.220.0040.00416.98
8.0.210.0040.00417.05
8.0.200.0030.00517.13
8.0.190.0040.00417.00
8.0.180.0000.00717.07
8.0.170.0040.00416.96
8.0.160.0040.00417.09
8.0.150.0020.00517.04
8.0.140.0040.00417.04
8.0.130.0060.00013.47
8.0.120.0040.00416.96
8.0.110.0070.00016.92
8.0.100.0040.00416.95
8.0.90.0040.00416.89
8.0.80.0040.01217.03
8.0.70.0040.00417.05
8.0.60.0070.00016.86
8.0.50.0000.00817.07
8.0.30.0110.00516.98
8.0.20.0130.01117.40
8.0.10.0000.00717.20
8.0.00.0070.01116.78
7.4.330.0020.00215.08
7.4.320.0000.00716.73
7.4.300.0030.00316.75
7.4.290.0030.00316.72
7.4.280.0030.00716.77
7.4.270.0000.00716.75
7.4.260.0000.00816.80
7.4.250.0000.00816.66
7.4.240.0020.00516.75
7.4.230.0000.00716.57
7.4.220.0190.01016.93
7.4.210.0070.00716.70
7.4.200.0030.00316.67
7.4.160.0090.00916.61
7.4.150.0140.00617.40
7.4.140.0130.00617.86
7.4.130.0050.01416.68
7.4.120.0090.01116.70
7.4.110.0150.00616.69
7.4.100.0060.01116.77
7.4.90.0090.00916.69
7.4.80.0100.00719.39
7.4.70.0030.01316.71
7.4.60.0120.00616.72
7.4.50.0090.00016.70
7.4.40.0120.00616.86
7.4.30.0200.00316.81
7.4.00.0100.00715.13
7.3.330.0000.00613.39
7.3.320.0020.00313.63
7.3.310.0030.00316.54
7.3.300.0070.00016.50
7.3.290.0060.00916.49
7.3.280.0060.01216.52
7.3.270.0120.00617.40
7.3.260.0110.00616.55
7.3.250.0020.01716.66
7.3.240.0100.00716.61
7.3.230.0070.01016.71
7.3.210.0120.00616.78
7.3.200.0090.00616.55
7.3.190.0090.00616.74
7.3.180.0090.01216.64
7.3.170.0090.00816.66
7.3.160.0080.01116.43
7.3.120.0000.01815.03
7.3.110.0070.01015.18
7.3.100.0070.00714.64
7.3.90.0070.00715.15
7.3.80.0030.00614.98
7.3.70.0030.01315.15
7.3.60.0040.01115.06
7.3.50.0060.00914.81
7.3.40.0130.00614.85
7.3.30.0090.00015.01
7.3.20.0090.00616.83
7.3.10.0090.00616.80
7.3.00.0060.00916.93
7.2.330.0090.00916.89
7.2.320.0080.00916.85
7.2.310.0070.01016.81
7.2.300.0130.00316.89
7.2.290.0120.00816.85
7.2.250.0110.00715.24
7.2.240.0000.02015.42
7.2.230.0040.00815.27
7.2.220.0060.00915.16
7.2.210.0000.01815.30
7.2.200.0100.00315.11
7.2.190.0030.01315.09
7.2.180.0070.01014.99
7.2.170.0070.01315.02
7.2.60.0070.00717.27
7.2.00.0000.01219.42
7.1.330.0120.00315.90
7.1.320.0070.00716.11
7.1.310.0090.00916.10
7.1.300.0040.01115.98
7.1.290.0090.00616.04
7.1.280.0070.00315.96
7.1.270.0030.00916.00
7.1.260.0030.00915.96
7.1.200.0000.00716.03
7.1.100.0100.00318.46
7.1.70.0070.01017.41
7.1.60.0060.01019.20
7.1.50.0070.01117.16
7.1.00.0030.07722.37
7.0.200.0000.00716.84
7.0.60.0100.08019.96
7.0.50.0130.04317.92
7.0.40.0030.09320.07
7.0.30.0230.08020.11
7.0.20.0230.04020.21
7.0.10.0070.08720.21
7.0.00.0000.04720.22
5.6.280.0030.07021.13
5.6.210.0100.07020.52
5.6.200.0000.09018.29
5.6.190.0030.04320.62
5.6.180.0270.07020.53
5.6.170.0300.05320.55
5.6.160.0130.08320.44
5.6.150.0170.04318.21
5.6.140.0100.07718.20
5.6.130.0000.04318.26
5.6.120.0100.03321.01
5.6.110.0030.09021.03
5.6.100.0030.07021.03
5.6.90.0130.04720.98
5.6.80.0100.08020.43
5.5.350.0030.03020.34
5.5.340.0070.08017.94
5.5.330.0070.08320.43
5.5.320.0330.04320.34
5.5.310.0270.08720.24
5.5.300.0100.07718.08
5.5.290.0030.08017.95
5.5.280.0030.04320.77
5.5.270.0000.07320.78
5.5.260.0070.07720.86
5.5.250.0070.05020.79
5.5.240.0270.05020.35
5.4.450.0570.08019.20
5.4.440.0700.06019.46
5.4.430.0730.05319.33
5.4.420.0830.05019.55
5.4.410.0500.05719.07
5.4.400.0770.05019.24
5.4.390.0670.06019.37
5.4.380.0900.05319.29
5.4.370.0670.05318.88
5.4.360.0700.05318.89
5.4.350.0670.04718.98
5.4.340.0600.05318.87
5.4.320.0230.05319.26
5.4.310.0570.06018.98
5.4.300.0830.05019.25
5.4.290.0730.05319.16
5.4.280.0030.06719.25
5.4.270.0200.06019.15
5.4.260.0800.05319.30
5.4.250.0670.05718.86
5.4.240.0270.06019.21
5.4.230.0530.04719.10
5.4.220.1070.06719.27
5.4.210.0770.04318.85
5.4.200.0670.05019.24
5.4.190.0770.05719.00
5.4.180.0830.06319.25
5.4.170.0800.05318.97
5.4.160.0670.06719.26
5.4.150.0670.06019.23
5.4.140.0470.08716.44
5.4.130.0870.07016.60
5.4.120.0830.06716.54
5.4.110.1100.06016.30
5.4.100.0870.06016.57
5.4.90.0600.06016.56
5.4.80.0700.06716.64
5.4.70.0170.03316.23
5.4.60.0000.03716.43
5.4.50.0070.07316.23
5.4.40.0170.05316.43
5.4.30.0370.06016.44
5.4.20.0230.03716.53

preferences:
50.01 ms | 400 KiB | 5 Q