3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* IMPORT SPORTS CATEGORIES */ foreach ($wanted_languages as $lang) { echo "import categories for lang=$lang\n"; $url = "https://www.bet3000.com/".$lang."/jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories"; try { $data = file_get_contents($url); $data = json_decode($data, true); $query = "UPDATE home_categories SET active=0"; if (!$debug) { mysql_query($query); } $cat_lvl_ids[0] = array("id" => 0,"label" => ""); $prev_lvl = 0; $parent_id = 0; $index = 0; $flag = false; $sortid=0; foreach ($data ['categories'] as $key => $value){ $sortid++; $cat = new Category($value); $lvl = $cat->get_level(); $id = $cat->get_id(); $active = $cat->get_activated_id(); $cat_lvl_ids[$lvl]["id"] = $id; $parent_id = $cat_lvl_ids[$lvl-1]["id"]; $parent_lbl = ""; if(!empty($cat_lvl_ids[$lvl-1]["label"])) { $parent_lbl = $cat_lvl_ids[$lvl-1]["label"]." / "; } $path = $parent_lbl . $cat->get_label(); $cat_lvl_ids[$lvl]["label"] = $path; $explode = explode(" / ",$path); $detail = $explode[count($explode)-1]; $sport = $explode[0]; $qcheck="SELECT * FROM `home_categories` WHERE cid=".$id." AND lang='".$lang."'"; $rcheck=mysql_query($qcheck); if (mysql_num_rows($rcheck)>0) { $ocheck=mysql_fetch_object($rcheck); $sqladd =""; $sqladd.= ",path='".trim(mysql_real_escape_string($path))."', detail='".trim(mysql_real_escape_string($detail))."'"; // UPDATE path,detail,sortid,active $querynew="UPDATE home_categories SET active=".$active.",sortid=".$sortid.$sqladd." WHERE cid=".$id." AND lang='".$lang."'"; mysql_query($querynew); echo mysql_error(); } else { $sqlheaderadd=""; $sqladd =""; $query = "INSERT IGNORE INTO `home_categories` (cid,lang,detail,path,topcatid,stufe,sport,sortid,active) VALUES (". $id.", ". "'".$lang."', ". "'".trim(mysql_real_escape_string($detail))."', ". "'".trim(mysql_real_escape_string($path))."', ". $parent_id.", ". $lvl.", ". "'".trim(mysql_real_escape_string($sport))."', ". $sortid.", ". $active. ")"; $resultInsert = mysql_query($query); if(!$resultInsert) echo mysql_error()."<br>$query"; } $prev_lvl = $lvl; } //foreach($result as $v) { // echo $value."<br>"; //} } catch(Exception $e) { echo $e->getMessage(); } } echo 'Categories added to database'; class Category { private $id; private $lvl; private $label; private $activated_id; private $children; public function __construct($cat) { $this->id = $cat['id']; $this->lvl = $cat['level']; $this->label = $cat['label']; $this->activated_id = $cat['activated_id']; $this->children = array(); } public function get_id() { return $this->id; } public function get_level() { return $this->lvl; } public function get_label() { return $this->label; } public function get_activated_id() { return $this->activated_id; } public function get_children() { return $this->children; } public function set_id($id) { $this->id = $id; } public function set_level($lvl) { $this->lvl = $lvl; } public function set_label($label) { $this->label = $label; } public function set_children($children) { $this->children = $children; } public function add_child($child) { $this->children[] = $child; } public function get_child($index) { return $this->children[$index]; } public function remove_child($child,$index) { $this->children[] = null; } public function __toString() { return "Category Lvl:".$this->get_level()." - ".$this->get_id(). ":".$this->get_label(); } }

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.0120.00316.63
8.3.50.0090.00917.80
8.3.40.0150.00018.81
8.3.30.0110.00418.67
8.3.20.0040.00420.33
8.3.10.0070.00023.68
8.3.00.0040.00419.25
8.2.180.0060.00916.75
8.2.170.0100.01022.96
8.2.160.0070.00720.47
8.2.150.0000.00724.18
8.2.140.0080.00024.66
8.2.130.0090.00017.75
8.2.120.0040.00426.35
8.2.110.0030.00620.47
8.2.100.0040.00718.05
8.2.90.0050.00319.36
8.2.80.0000.00917.97
8.2.70.0060.00317.74
8.2.60.0000.00917.80
8.2.50.0080.00018.07
8.2.40.0080.00019.51
8.2.30.0060.00320.79
8.2.20.0040.00417.67
8.2.10.0040.00417.98
8.2.00.0040.00418.01
8.1.270.0070.00323.96
8.1.260.0050.00328.09
8.1.250.0040.00428.09
8.1.240.0040.00422.39
8.1.230.0040.00717.66
8.1.220.0000.00917.74
8.1.210.0080.00018.77
8.1.200.0060.00317.35
8.1.190.0030.00517.35
8.1.180.0080.00018.10
8.1.170.0040.00419.21
8.1.160.0020.00522.03
8.1.150.0040.00418.89
8.1.140.0000.00919.54
8.1.130.0040.00417.72
8.1.120.0040.00417.49
8.1.110.0000.00717.54
8.1.100.0040.00417.47
8.1.90.0030.00617.43
8.1.80.0060.00317.52
8.1.70.0040.00417.46
8.1.60.0000.00917.53
8.1.50.0060.00317.61
8.1.40.0040.00417.47
8.1.30.0040.00417.59
8.1.20.0000.00817.55
8.1.10.0040.00417.60
8.1.00.0000.00817.46
8.0.300.0030.00618.77
8.0.290.0020.00517.00
8.0.280.0070.00018.44
8.0.270.0070.00417.30
8.0.260.0040.00417.30
8.0.250.0070.00017.00
8.0.240.0030.00317.04
8.0.230.0080.00016.98
8.0.220.0040.00416.94
8.0.210.0040.00416.94
8.0.200.0000.00717.07
8.0.190.0080.00017.08
8.0.180.0000.00816.93
8.0.170.0090.00017.03
8.0.160.0050.00317.07
8.0.150.0030.00516.84
8.0.140.0040.00416.84
8.0.130.0030.00313.43
8.0.120.0050.00316.95
8.0.110.0030.00516.98
8.0.100.0070.00016.84
8.0.90.0020.00517.07
8.0.80.0130.00916.92
8.0.70.0040.00416.88
8.0.60.0040.00416.99
8.0.50.0060.00316.78
8.0.30.0100.01017.15
8.0.20.0090.01417.42
8.0.10.0000.00817.01
8.0.00.0080.00916.75
7.4.330.0050.00016.73
7.4.320.0030.00316.64
7.4.300.0000.00716.56
7.4.290.0070.00016.66
7.4.280.0080.00016.57
7.4.270.0000.00716.70
7.4.260.0000.00716.59
7.4.250.0040.00416.45
7.4.240.0050.00316.55
7.4.230.0050.00216.49
7.4.220.0030.01616.58
7.4.210.0100.00716.71
7.4.200.0050.00216.54
7.4.160.0090.00616.56
7.4.150.0040.01417.40
7.4.140.0170.00917.86
7.4.130.0130.00616.54
7.4.120.0120.00616.55
7.4.110.0120.01216.53
7.4.100.0100.00716.47
7.4.90.0140.00516.61
7.4.80.0120.00619.39
7.4.70.0070.01016.58
7.4.60.0080.00816.63
7.4.50.0060.00616.39
7.4.40.0120.00616.63
7.4.30.0120.00616.62
7.4.00.0070.01115.08
7.3.330.0060.00013.48
7.3.320.0000.00613.27
7.3.310.0050.00216.36
7.3.300.0030.00316.42
7.3.290.0030.00316.26
7.3.280.0090.00816.39
7.3.270.0120.00617.40
7.3.260.0040.01316.77
7.3.250.0100.01116.52
7.3.240.0080.01316.57
7.3.230.0130.00716.61
7.3.210.0480.01716.44
7.3.200.0040.01416.65
7.3.190.0060.00316.46
7.3.180.0040.01216.45
7.3.170.0080.01516.43
7.3.160.0060.01016.54
7.3.10.0060.00616.35
7.3.00.0000.01516.62
7.2.330.0040.01316.75
7.2.320.0030.01516.49
7.2.310.0110.00916.75
7.2.300.0120.00616.66
7.2.290.0060.01116.74
7.2.130.0070.00717.03
7.2.120.0090.00616.98
7.2.110.0090.00916.50
7.2.100.0040.00816.80
7.2.90.0030.01316.91
7.2.80.0000.01516.92
7.2.70.0030.00916.99
7.2.60.0080.00716.84
7.2.50.0030.00616.59
7.2.40.0080.00416.96
7.2.30.0030.00716.95
7.2.20.0040.00816.82
7.2.10.0070.00816.68
7.2.00.0020.01418.13
7.1.250.0070.00315.45
7.1.200.0090.00315.27
7.1.100.0120.00617.90
7.1.70.0040.00417.09
7.1.60.0040.00817.22
7.1.50.0160.00616.84
7.1.00.0030.07722.42
7.0.200.0000.00816.73
7.0.60.0030.04720.16
7.0.50.0000.06317.96
7.0.40.0230.07320.12
7.0.30.0230.07320.24
7.0.20.0230.08020.22
7.0.10.0170.05020.12
7.0.00.0100.04020.09
5.6.280.0000.03320.95
5.6.210.0070.08720.60
5.6.200.0070.08318.23
5.6.190.0070.07720.46
5.6.180.0370.07320.41
5.6.170.0200.04720.39
5.6.160.0130.07720.71
5.6.150.0100.06718.18
5.6.140.0230.06018.30
5.6.130.0030.04718.17
5.6.120.0070.04320.93
5.6.110.0100.07721.04
5.6.100.0200.05721.05
5.6.90.0100.06721.13
5.6.80.0070.06320.41
5.5.350.4230.04720.37
5.5.340.0030.08317.97
5.5.330.0100.04020.37
5.5.320.0000.05020.42
5.5.310.0270.03020.23
5.5.300.0030.08318.05
5.5.290.0030.04018.18
5.5.280.0100.08020.81
5.5.270.0130.07020.99
5.5.260.0070.08320.79
5.5.250.0100.06720.53
5.5.240.0330.05020.19

preferences:
63.99 ms | 400 KiB | 5 Q