3v4l.org

run code in 300+ PHP versions simultaneously
<?php function curl($url) { $options = Array( CURLOPT_RETURNTRANSFER => TRUE, // Setting cURL's option to return the webpage data CURLOPT_FOLLOWLOCATION => TRUE, // Setting cURL to follow 'location' HTTP headers CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers CURLOPT_CONNECTTIMEOUT => 120, // Setting the amount of time (in seconds) before the request times out CURLOPT_TIMEOUT => 120, // Setting the maximum amount of time for cURL to execute queries CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8", // Setting the useragent CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function ); $ch = curl_init(); // Initialising cURL curl_setopt_array($ch, $options); // Setting cURL's options using the previously assigned array data in $options $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable curl_close($ch); // Closing cURL return $data; // Returning the data from the function } function regex_scrape($regex,$results_page){ preg_match_all($regex,$results_page,$match); return $match; } $continue = TRUE; $prices = array(); $url = "https://www.airbnb.de/s/Prague~Prague-1--Czech-Republic"; while ($continue == TRUE) { $results_page = curl($url); // Downloading the results page using our curl() funtion $prices2 = regex_scrape('/<span class=\"h3 price-amount\">(.*)span>/',$results_page); //PRINTING ARRAY SUM NOT WORKIN var_dump($prices2[0]); echo 'TOTAL: ' . array_sum(array_values($prices2[0])); $prices = array_merge($prices,$prices2[0]); if (strpos($results_page, "<li class=\"next next_page\">")) { $continue = FALSE; preg_match('/<li class="next next_page"><a target=".*" rel="next" href="(.*)"><i class="icon icon-caret-right">/',$results_page,$url); $url = 'https://www.airbnb.de' . $url[1]; } else { $continue = FALSE; // Setting $continue to FALSE if there's no 'Next' link } sleep(rand(0,1)); // Sleep for 3 to 5 seconds. Useful if not using proxies. We don't want to get into trouble. } ?>

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.2.00.0060.00818.91
7.1.70.0000.01417.18
7.1.60.0030.02319.32
7.1.50.0040.01716.92
7.1.00.0070.07722.45
7.0.200.0000.01116.75
7.0.140.0000.07322.16
7.0.60.0000.07319.88
7.0.50.0030.09017.84
7.0.40.0100.07019.96
7.0.30.0270.05720.08
7.0.20.0330.06320.33
7.0.10.0130.08320.23
7.0.00.0100.09020.12
5.6.280.0030.07321.12
5.6.210.0070.09020.57
5.6.200.0270.06318.20
5.6.190.0130.07020.55
5.6.180.0270.05320.50
5.6.170.0270.08020.45
5.6.160.0030.05020.58
5.6.150.0000.04318.34
5.6.140.0070.03318.14
5.6.130.0100.08018.28
5.6.120.0030.04720.98
5.6.110.0030.04020.96
5.6.100.0100.08320.98
5.6.90.0100.08020.99
5.6.80.0070.05320.50
5.6.70.4600.04320.39
5.5.350.0230.06720.38
5.5.340.0070.08017.98
5.5.330.0200.07320.21
5.5.320.0300.07320.39
5.5.310.0300.04020.34
5.5.300.0030.04017.95
5.5.290.0070.04018.05
5.5.280.0100.03720.88
5.5.270.0030.08320.77
5.5.260.0100.08320.80
5.5.250.0100.08020.67
5.5.240.0330.06720.36
5.4.450.0300.05319.62
5.4.440.0770.07019.20
5.4.430.0870.05319.33
5.4.420.0100.07719.41
5.4.410.0100.05719.54
5.4.400.0130.05019.33
5.4.390.0200.05319.05
5.4.380.0030.06019.02
5.4.370.0230.06019.02
5.4.360.0100.07319.03
5.4.350.0170.04719.13
5.4.340.0060.03512.02
5.4.320.0090.03612.52
5.4.310.0140.04212.51
5.4.300.0050.04712.51
5.4.290.0080.03812.51
5.4.280.0030.04112.41
5.4.270.0050.03812.41
5.4.260.0080.03712.41
5.4.250.0070.04412.40
5.4.240.0110.03912.41
5.4.230.0060.04612.40
5.4.220.0090.03712.40
5.4.210.0060.04012.40
5.4.200.0030.04612.39
5.4.190.0100.03512.39
5.4.180.0090.03912.39
5.4.170.0070.04112.40
5.4.160.0070.03612.40
5.4.150.0070.03512.39
5.4.140.0060.03712.08
5.4.130.0060.03612.07
5.4.120.0080.03312.02
5.4.110.0100.03312.02
5.4.100.0060.03512.02
5.4.90.0080.03812.02
5.4.80.0080.04312.02
5.4.70.0040.04212.01
5.4.60.0070.03512.02
5.4.50.0060.04312.02
5.4.40.0070.03712.01
5.4.30.0070.03412.00
5.4.20.0070.04112.00
5.4.10.0100.03112.00
5.4.00.0090.03411.50
5.3.290.0100.04512.80
5.3.280.0060.03912.71
5.3.270.0080.03912.72
5.3.260.0050.04212.72
5.3.250.0060.03812.71
5.3.240.0070.03712.72
5.3.230.0070.06112.71
5.3.220.0070.04012.68
5.3.210.0080.04412.68
5.3.200.0070.03612.68
5.3.190.0110.04112.68
5.3.180.0090.05112.68
5.3.170.0060.03712.67
5.3.160.0080.04112.68
5.3.150.0060.04412.68
5.3.140.0100.03512.66
5.3.130.0080.03712.66
5.3.120.0030.04312.66
5.3.110.0080.03712.66
5.3.100.0070.03712.13
5.3.90.0110.03112.11
5.3.80.0040.03812.10
5.3.70.0070.03712.10
5.3.60.0060.03712.08
5.3.50.0070.04412.03
5.3.40.0040.04012.04
5.3.30.0040.03911.99
5.3.20.0100.03411.77
5.3.10.0100.04511.73
5.3.00.0090.03911.72
5.2.170.0130.0879.23
5.2.160.0050.0339.23
5.2.150.0080.0359.23
5.2.140.0040.0369.23
5.2.130.0090.0309.19
5.2.120.0090.0289.19
5.2.110.0060.0359.20
5.2.100.0050.0389.20
5.2.90.0060.0369.20
5.2.80.0080.0599.18
5.2.70.0070.0369.18
5.2.60.0080.0339.14
5.2.50.0090.0389.11
5.2.40.0060.0329.09
5.2.30.0080.0319.05
5.2.20.0050.0339.05
5.2.10.0060.0378.96
5.2.00.0060.0288.82
5.1.60.0050.0248.10
5.1.50.0060.0248.09
5.1.40.0050.0258.08
5.1.30.0030.0288.42
5.1.20.0040.0288.45
5.1.10.0050.0268.17
5.1.00.0050.0268.17
5.0.50.0030.0216.67
5.0.40.0050.0196.52
5.0.30.0050.0326.34
5.0.20.0050.0186.30
5.0.10.0040.0216.28
5.0.00.0040.0326.27
4.4.90.0010.0174.77
4.4.80.0020.0174.75
4.4.70.0020.0184.75
4.4.60.0030.0174.76
4.4.50.0020.0194.77
4.4.40.0050.0244.71
4.4.30.0020.0174.76
4.4.20.0030.0164.85
4.4.10.0040.0154.85
4.4.00.0030.0264.76
4.3.110.0020.0164.67
4.3.100.0040.0164.67
4.3.90.0010.0194.63
4.3.80.0020.0274.58
4.3.70.0020.0164.63
4.3.60.0050.0134.63
4.3.50.0020.0164.63
4.3.40.0040.0264.54
4.3.30.0020.0173.32
4.3.20.0010.0183.30
4.3.10.0020.0163.26
4.3.00.0030.0206.88

preferences:
43.31 ms | 401 KiB | 5 Q