3v4l.org

run code in 300+ PHP versions simultaneously
<?php case 'updateprice': switch ($task) { case 'update': { if(isset($HTTP_POST_FILES['filename']['name'])) { echo "<h3>Uploading: ".$HTTP_POST_FILES['filename']['name']."</h3><br>"; $handle=fopen($HTTP_POST_FILES['filename']['tmp_name'],"r"); if ($handle) { if (!feof($handle)) $buffer = fgets($handle); while (!feof($handle)&&!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { $buffer = fgets($handle); } if(!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { echo "<h3>Incorrect file<h3>"; exit; } else { $columns=explode("\t",$buffer); $i=0; foreach ($columns as $column) { $column=iconv("WINDOWS-1251","UTF-8",$column); if ($column=="Розница") $price1=$i; if ($column=="Опт1") $price2=$i; if ($column=="Опт2") $price3=$i; if ($column=="Опт3") $price4=$i; if ($column=="Код") $code=$i; $i++; } } echo $database->doSQL("DROP TABLE IF EXISTS #__import"); echo $database->doSQL("CREATE TABLE IF NOT EXISTS #__import ( `code` bigint(20) unsigned NOT NULL, `price1` float NOT NULL default '0', `price2` float NOT NULL default '0', `price3` float NOT NULL default '0', `price4` float NOT NULL default '0', KEY `code` (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"); $buffer = fgets($handle); while (!feof($handle)) { $buffer = fgets($handle); $row = explode("\t",$buffer); if (array_key_exists(9,$row)) { $out=array("'"," руб."); $row[$price1] = str_replace($out,"",$row[$price1]); $row[$price2] = str_replace($out,"",$row[$price2]); $row[$price3] = str_replace($out,"",$row[$price3]); $row[$price4] = str_replace($out,"",$row[$price4]); $sql = "INSERT INTO #__import (`code`, `price1`, `price2`, `price3`, `price4`) VALUES ('$row[$code]', '$row[$price1]', '$row[$price2]', '$row[$price3]', '$row[$price4]');"; $result = $database->doSQL($sql); } } fclose($handle); } echo "<h3>Import completed</h3><br />"; $database->doSQL("UPDATE #__itemdetails SET `price1` = 0, `price2` = 0, `price3` = 0, `price4` = 0"); echo '<h3>Old prices was nulled</h3><br>'; $sql=""; $database->setQuery('select * from #__itemdetails'); $rows = $database->loadObjectList(); foreach ($rows as $row) { $database->setQuery("select * from #__import where code=$row->code"); $rows1=$database->loadObjectList(); if (!sizeof($rows1)) $errors.=$row->code.', '; else { $database->doSQL("UPDATE #__itemdetails SET `price1` = '".$rows1[0]->price1."', `price2` = '".$rows1[0]->price2."', `price3` = '".$rows1[0]->price3."', `price4` = '".$rows1[0]->price4."' WHERE `code` = ".$row->code); $completed.=$row->code.', '; } } echo '<div align=left><b>The following goods were updated:</b> '.substr($completed,0,strlen($completed)-2).'</div>'; if (isset($errors)) echo '<br><br><div align=left><b><font color=red>The following goods were not found:</b></font> '.substr($errors,0,strlen($errors)-2).'</div>'; exit; } } default: HTML_catalog::ShowUploadPriceForm(); break; } break; ?>

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.210.0190.04412.37
5.4.200.0220.04712.37
5.4.190.0260.05312.37
5.4.180.0240.04012.36
5.4.170.0160.04312.37
5.4.160.0180.04812.36
5.4.150.0190.04412.36
5.4.140.0210.04912.06
5.4.130.0180.04512.03
5.4.120.0200.04812.00
5.4.110.0190.04612.00
5.4.100.0220.04912.00
5.4.90.0180.04912.00
5.4.80.0190.04312.00
5.4.70.0190.04412.00
5.4.60.0250.04111.99
5.4.50.0150.04911.99
5.4.40.0180.04811.98
5.4.30.0140.05011.98
5.4.20.0200.04311.97
5.4.10.0180.04411.98
5.4.00.0150.04511.48
5.3.270.0170.04812.72
5.3.260.0200.04412.72
5.3.250.0170.05312.72
5.3.240.0180.05012.72
5.3.230.0160.05112.71
5.3.220.0160.04612.68
5.3.210.0240.04412.68
5.3.200.0200.04612.68
5.3.190.0150.04812.68
5.3.180.0190.04912.67
5.3.170.0240.03912.67
5.3.160.0140.04912.67
5.3.150.0200.04612.67
5.3.140.0190.04212.66
5.3.130.0160.04912.65
5.3.120.0220.04612.66
5.3.110.0200.04312.66
5.3.100.0200.04412.12
5.3.90.0280.06312.09
5.3.80.0140.04912.08
5.3.70.0220.05312.07
5.3.60.0230.04212.06
5.3.50.0230.03912.00
5.3.40.0220.04512.00
5.3.30.0180.04311.94
5.3.20.0190.04511.71
5.3.10.0130.04611.68
5.3.00.0140.04711.66

preferences:
139.95 ms | 1394 KiB | 7 Q