3v4l.org

run code in 300+ PHP versions simultaneously
<?php $t=time(); //csv file write #$filename=date("Y-m-d",$t)."_work.csv"; $filename=$t."_data.csv"; $handle = fopen($filename, "w"); //Header for csv file $business = array("Business Name" , "Address1" ,"City","State","Zip code","Address2","Phone" , "Website" ,"Yelp Url"); fputcsv($handle,$business); $start=0; $csv_records = array(); for ($i = 0; $i <= 100; $i++) { $start=$i*10;//start count for pagination $args = $_SERVER['argv']; //$html = file_get_contents($args[1].'&start='.$start); $html = file_get_contents('http://www.yelp.com/search?find_desc=tasty+burger&find_loc=San+Francisco%2C+CA&start=10', 'w'); if(!empty($html)){ $pokemon_doc = new DOMDocument(); libxml_use_internal_errors(TRUE); //disable libxml errors $pokemon_doc->loadHTML($html); libxml_clear_errors(); //remove errors for yucky html $pokemon_xpath = new DOMXPath($pokemon_doc); //get all the span's with an class for getting Url $pokemon_row = $pokemon_xpath->query('/html/body//span[@class="indexed-biz-name"]/a'); $biz = array(); if($pokemon_row->length > 0){ foreach($pokemon_row as $row){ $biz['name'] = $row->nodeValue; $url1 = $row->getAttribute("href"); $biz['yelp_url'] = "http://www.yelp.com".$url1; $html1 = file_get_contents("http://www.yelp.com/".$url1); $pokemon_doc1 = new DOMDocument(); libxml_use_internal_errors(TRUE); $pokemon_doc1->loadHTML($html1); libxml_clear_errors(); //remove errors for yucky html $pokemon_xpath1 = new DOMXPath($pokemon_doc1); //get all the h2's with an id $pokemon_row1 = $pokemon_xpath1->query('/html/body//div[@class="mapbox-text"]/ul/li'); $biz['address'] = $pokemon_row1->item(0)->nodeValue; $biz['phone'] = $pokemon_row1->item(2)->nodeValue; if(preg_match('/Business website/',$pokemon_row1->item(3)->nodeValue)){ $biz['website']= $pokemon_row1->item(3)->nodeValue; } else{ $biz['website']= $pokemon_row1->item(4)->nodeValue; } //$biz['website'] ="http://".ltrim($bizwebsite,1); /* ############# Code to remove extra spaces and new line chars*/ $line_out_name = preg_replace('/[\n\r]+/', '', $biz['name']); $business_details_name = preg_replace('/[\s]+/', ' ', $line_out_name); $line_out_address = preg_replace('/[\r]+/', '', $biz['address']); $business_details_address = preg_replace('/[\s]+/', ' ', $line_out_address); $business_address=explode(",",$business_details_address); $add1=explode(" ",$business_address[0]); $add=$add1[0]." ".$add1[1]." ".$add1[2]; $add1=$add1[3]." ".$add1[4]; $add2=explode("b/t",$business_address[1]); $s=explode(" ",$add2[0]); $state=$s[1]; $zip=$s[2]; $lastadd="b/t".$add2[1]; $line_out_phone = preg_replace('/[\n\r]+/', '', $biz['phone']); $business_details_phone = preg_replace('/[\s]+/', ' ', $line_out_phone); $business_details_phone = preg_replace('/Phone number/','', $business_details_phone); $line_out_website = preg_replace('/[\n\r]+/', '', $biz['website']); $business_details_website = preg_replace('/Business website/','', $line_out_website); $business_details_website = preg_replace('/[\s]+/', '', $business_details_website); $business_details_website = "http://".$business_details_website; $business[0]= stripslashes(htmlspecialchars($business_details_name)); $business[1]= stripslashes($add); $business[2]= stripslashes($add1); $business[3]= stripslashes($state); $business[4]= stripslashes($zip); $business[5]= stripslashes($lastadd); $business[6]= stripslashes($business_details_phone); $business[7]= stripslashes($business_details_website); $business[8]= stripslashes($biz['yelp_url']); array_push($csv_records,($business[0]),$business[1],$business[2],$business[3],$business[4],$business[5],$business[6],$business[7],$business[8]); if (false !== $handle) { fputcsv($handle,$csv_records); } $csv_records = array(); } #foreach ends $pokemon_row } #if ends $pokemon_row->length > 0 }#if(!empty($html)) $business1 = ""; }#for ($i = 1; $i < 5; $i++) end ?>

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.80.0270.00416.38
7.2.60.0150.01317.14
7.2.00.0140.01119.63
7.1.200.0120.01116.18
7.1.100.0220.00718.63
7.1.70.0040.00817.45
7.1.60.0070.01820.03
7.1.50.0140.00317.11
7.1.00.0130.08022.86
7.0.200.0080.00317.18
7.0.100.0200.03720.46
7.0.90.0170.08720.38
7.0.80.0100.08320.30
7.0.70.0130.04020.42
7.0.60.0200.08020.54
7.0.50.0170.06320.77
7.0.40.0230.06720.45
7.0.30.0230.08720.41
7.0.20.0100.05720.43
7.0.10.0130.05720.54
7.0.00.0200.07320.30
5.6.280.0130.06321.46
5.6.250.0170.09321.16
5.6.240.0130.05721.07
5.6.230.0100.05721.12
5.6.220.0200.07721.07
5.6.210.0100.04321.21
5.6.200.0070.04721.42
5.6.190.0130.09021.50
5.6.180.0200.04321.28
5.6.170.0230.09721.53
5.6.160.0300.09021.39
5.6.150.0130.05321.36
5.6.140.0100.07721.52
5.6.130.0130.09021.40
5.6.120.0200.07321.50
5.6.110.0170.09021.34
5.6.100.0100.08321.28
5.6.90.0100.04721.38
5.6.80.0200.08721.02
5.6.70.0130.05720.80
5.6.60.0170.08320.81
5.6.50.0200.07320.79
5.6.40.0170.08020.78
5.6.30.0230.07720.66
5.6.20.0230.07320.83
5.6.10.0200.05320.73
5.6.00.0170.04720.85
5.5.380.0230.06721.04
5.5.370.0170.04020.93
5.5.360.0130.09020.89
5.5.350.0100.05720.89
5.5.340.0230.07721.10
5.5.330.0230.08021.24
5.5.320.0300.06021.24
5.5.310.0230.04321.25
5.5.300.0270.07721.20
5.5.290.0230.07721.25
5.5.280.0170.04321.23
5.5.270.0130.08721.25
5.5.260.0130.07321.38
5.5.250.0100.07021.08
5.5.240.0230.08320.77
5.5.230.0170.07720.49
5.5.220.0130.07320.59
5.5.210.0200.08320.52
5.5.200.0130.06320.50
5.5.190.0230.07720.64
5.5.180.0200.07720.49
5.5.160.0300.07020.40
5.5.150.0300.09720.58
5.5.140.0270.07320.66
5.5.130.0200.08320.60
5.5.120.0200.07320.50
5.5.110.0300.07020.57
5.5.100.0230.06320.52
5.5.90.0170.04720.47
5.5.80.0170.07720.60
5.5.70.0170.06320.46
5.5.60.0270.07320.34
5.5.50.0300.07020.53
5.5.40.0130.04720.48
5.5.30.0100.07020.55
5.5.20.0170.05720.48
5.5.10.0130.08320.59
5.5.00.0070.05320.54
5.4.450.0200.04019.66
5.4.440.0130.09319.94
5.4.430.0100.08319.71
5.4.420.0230.07019.72
5.4.410.0170.04719.57
5.4.400.0070.07319.43
5.4.390.0200.07719.42
5.4.380.0130.07719.36
5.4.370.0170.07319.43
5.4.360.0130.07319.36
5.4.350.0130.05319.31
5.4.340.0130.05019.44
5.4.320.0100.05019.46
5.4.310.0170.08019.27
5.4.300.0230.08019.43
5.4.290.0270.07719.31
5.4.280.0200.09019.31
5.4.270.0100.08719.31
5.4.260.0200.08019.43
5.4.250.0270.07019.41
5.4.240.0230.04019.36
5.4.230.0300.06319.43
5.4.220.0330.03019.30
5.4.210.0230.07319.44
5.4.200.0200.06019.30
5.4.190.0170.05319.36
5.4.180.0300.06319.41
5.4.170.0230.05319.25
5.4.160.0200.08719.39
5.4.150.0330.07019.27
5.4.140.0200.06016.86
5.4.130.0100.04716.58
5.4.120.0170.04316.86
5.4.110.0270.09016.81
5.4.100.0130.07016.70
5.4.90.0270.06716.65
5.4.80.0170.07716.82
5.4.70.0200.06716.68
5.4.60.0130.07716.78
5.4.50.0300.06316.74
5.4.40.0230.08016.58
5.4.30.0170.08016.66
5.4.20.0200.07316.74
5.4.10.0230.04016.61
5.4.00.0170.06316.33

preferences:
39.42 ms | 401 KiB | 5 Q