3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar($tags, $product_row) { $path_arr = []; foreach ($product_row['fields'] as $field) { //gets the path for this field like pathto/field $strpath = $tags[$field['id']]['str_path']; $paths = explode('/', $strpath); $this->stringKeyToMultArray($path_arr, $paths, $field['value']); } return json_encode($path_arr, JSON_PRETTY_PRINT); } protected function stringKeyToMultArray(&$newarr, $keys, $value) { if (count($keys) > 1) { $key = array_shift($keys); if ( !isset($newarr[$key]) || !is_array($newarr[$key])) { $newarr[$key] = array(array()); } $this->stringKeyToMultArray($newarr[$key][0], $keys, $value); } else { $newarr[array_shift($keys)] = $value; } } } $foo = new Foo; $tags = array( 1 => array('str_path' => 'product_title'), 2 => array('str_path' => 'ASIN'), 3 => array('str_path' => 'codes/type'), 4 => array('str_path' => 'codes/number'), 5 => array('str_path' => 'quantity') ); $product_row = array('fields' => array( array('id' => 1, 'value' => 'Test Title'), array('id' => 2, 'value' => '1234567890'), array('id' => 3, 'value' => 'UPC'), array('id' => 4, 'value' => '030878249270'), array('id' => 3, 'value' => 'UPC'), )); echo $foo->bar($tags, $product_row);

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.5.10.0100.00719.85
8.5.00.0120.01020.02
8.4.150.0030.00014.05
8.4.140.0120.00917.55
8.4.130.0140.00819.55
8.4.120.0150.00522.47
8.4.110.0090.00222.68
8.4.100.0130.00817.58
8.4.90.0140.00618.53
8.4.80.0110.00917.68
8.4.70.0030.00617.95
8.4.60.0030.00618.61
8.4.50.0120.00819.59
8.4.40.0080.01219.39
8.4.30.0130.00717.77
8.4.20.0090.00017.75
8.4.10.0030.00617.58
8.3.280.0130.00818.25
8.3.270.0090.01016.58
8.3.260.0060.00216.45
8.3.250.0120.00718.81
8.3.240.0060.00718.96
8.3.230.0130.00816.79
8.3.220.0160.00217.11
8.3.210.0140.00616.56
8.3.200.0050.00416.63
8.3.190.0060.00417.32
8.3.180.0060.01318.48
8.3.170.0000.01817.29
8.3.160.0090.00916.70
8.3.150.0080.00818.83
8.3.140.0090.00916.52
8.3.130.0040.00418.42
8.3.120.0060.00320.57
8.3.110.0100.00616.75
8.3.100.0040.00424.06
8.3.90.0080.00026.77
8.3.80.0030.01017.97
8.3.70.0150.00016.48
8.3.60.0130.00918.30
8.3.50.0120.01021.98
8.3.40.0070.00718.83
8.3.30.0090.00618.70
8.3.20.0100.00320.16
8.3.10.0040.00420.46
8.3.00.0040.00420.64
8.2.290.0060.00420.29
8.2.280.0120.00818.31
8.2.270.0040.01616.81
8.2.260.0100.00720.87
8.2.250.0040.00416.70
8.2.240.0120.00318.71
8.2.230.0170.00020.94
8.2.220.0090.00037.54
8.2.210.0000.01926.77
8.2.200.0080.00016.50
8.2.190.0070.01118.32
8.2.180.0090.01216.50
8.2.170.0100.01022.96
8.2.160.0080.00819.21
8.2.150.0000.00724.18
8.2.140.0000.00824.66
8.2.130.0000.00819.51
8.2.120.0080.00026.35
8.2.110.0070.00421.18
8.2.100.0090.00318.03
8.2.90.0040.00419.52
8.2.80.0040.00420.36
8.2.70.0030.00517.63
8.2.60.0000.00818.16
8.2.50.0050.00318.10
8.2.40.0000.00720.47
8.2.30.0020.00520.52
8.2.20.0000.00817.63
8.2.10.0030.00618.21
8.2.00.0000.00818.09
8.1.330.0090.00921.80
8.1.320.0140.00516.13
8.1.310.0070.01116.95
8.1.300.0100.00017.73
8.1.290.0040.00430.84
8.1.280.0170.00325.92
8.1.270.0080.00023.99
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0060.00322.19
8.1.230.0040.00722.81
8.1.220.0000.00817.74
8.1.210.0040.00418.90
8.1.200.0060.00317.36
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0090.00018.59
8.1.160.0000.00720.82
8.1.150.0000.00718.95
8.1.140.0020.00517.45
8.1.130.0030.00317.79
8.1.120.0030.00317.37
8.1.110.0060.00317.41
8.1.100.0040.00417.51
8.1.90.0040.00417.38
8.1.80.0030.00517.36
8.1.70.0030.00317.52
8.1.60.0000.00817.59
8.1.50.0040.00417.58
8.1.40.0040.00417.52
8.1.30.0040.00417.58
8.1.20.0000.00817.56
8.1.10.0000.00817.43
8.1.00.0040.00417.50
8.0.300.0050.00220.11
8.0.290.0000.00816.58
8.0.280.0030.00318.33
8.0.270.0000.00717.32
8.0.260.0000.00717.26
8.0.250.0030.00316.89
8.0.240.0080.00016.95
8.0.230.0030.00516.94
8.0.220.0040.00416.79
8.0.210.0000.00716.91
8.0.200.0040.00416.83
8.0.190.0000.00816.91
8.0.180.0030.00916.94
8.0.170.0000.00816.85
8.0.160.0040.00417.04
8.0.150.0000.00716.86
8.0.140.0080.00016.75
8.0.130.0000.00613.35
8.0.120.0030.00616.96
8.0.110.0000.00716.79
8.0.100.0040.00416.79
8.0.90.0070.00016.77
8.0.80.0080.00816.95
8.0.70.0000.00716.76
8.0.60.0030.00516.92
8.0.50.0080.00016.70
8.0.30.0060.00917.18
8.0.20.0090.01117.40
8.0.10.0040.00417.13
8.0.00.0090.00916.83
7.4.330.0020.00215.08
7.4.320.0060.00316.50
7.4.300.0000.00616.40
7.4.290.0030.00616.60
7.4.280.0040.00416.61
7.4.270.0030.00316.62
7.4.260.0050.00316.49
7.4.250.0050.00316.52
7.4.240.0050.00216.57
7.4.230.0000.00716.68
7.4.220.0090.01316.51
7.4.210.0090.01216.39
7.4.200.0000.00716.71
7.4.160.0160.00016.47
7.4.150.0100.00717.40
7.4.140.0110.01017.86
7.4.130.0090.01516.52
7.4.120.0090.01016.50
7.4.110.0210.00316.54
7.4.100.0120.00616.49
7.4.90.0100.00716.64
7.4.80.0060.00919.39
7.4.70.0060.01016.50
7.4.60.0100.00716.57
7.4.50.0000.01516.46
7.4.40.0120.00416.50
7.4.30.0100.01316.48
7.4.00.0000.01615.08
7.3.330.0040.00413.23
7.3.320.0020.00213.36
7.3.310.0000.00716.38
7.3.300.0060.00016.26
7.3.290.0100.00716.37
7.3.280.0090.00816.36
7.3.270.0110.00617.40
7.3.260.0080.01316.82
7.3.250.0160.00716.43
7.3.240.0160.00616.31
7.3.230.0180.00316.39
7.3.210.0060.01516.29
7.3.200.0060.01016.53
7.3.190.0120.00316.39
7.3.180.0140.00716.63
7.3.170.0080.01416.55
7.3.160.0130.00316.40
7.3.120.0070.00714.97
7.3.110.0060.00915.04
7.3.100.0120.00315.01
7.3.90.0060.00614.82
7.3.80.0000.01415.08
7.3.70.0080.00815.00
7.3.60.0030.01314.59
7.3.50.0070.00314.54
7.3.40.0070.01014.80
7.3.30.0100.00714.99
7.3.20.0000.01116.82
7.3.10.0110.00416.62
7.3.00.0070.01116.76
7.2.330.0160.00916.60
7.2.320.0060.01516.55
7.2.310.0100.01216.85
7.2.300.0140.00316.47
7.2.290.0120.00416.57
7.2.240.0060.01215.39
7.2.230.0000.01215.15
7.2.220.0060.01214.80
7.2.210.0070.00715.33
7.2.200.0060.00815.04
7.2.190.0070.01014.74
7.2.180.0060.01115.13
7.2.170.0120.00315.29
7.2.160.0060.00914.92
7.2.150.0090.00616.94
7.2.140.0080.00416.93
7.2.130.0070.00716.70
7.2.120.0060.01316.96
7.2.110.0030.01016.90
7.2.100.0040.01317.08
7.2.90.0030.01116.94
7.2.80.0030.00616.88
7.2.70.0080.00617.06
7.2.60.0080.00816.89
7.2.50.0030.01017.17
7.2.40.0070.01016.93
7.2.30.0070.01016.84
7.2.20.0070.01116.74
7.2.10.0070.01017.12
7.2.00.0070.01016.98
7.1.330.0150.00015.84
7.1.320.0070.01015.78
7.1.310.0110.00415.93
7.1.300.0000.01815.79
7.1.290.0030.01315.76
7.1.280.0040.00815.73
7.1.270.0030.01315.90
7.1.260.0080.00815.98
7.1.250.0000.01516.03
7.1.200.0050.00315.93
7.1.70.0000.00917.02
7.1.60.0100.00319.48
7.1.00.0000.08022.51
7.0.200.0040.00416.77
7.0.90.0170.04020.02
7.0.80.0070.05020.04
7.0.70.0030.06019.96
7.0.60.0070.08319.89
7.0.50.0070.08320.41
7.0.40.0100.05320.00
7.0.30.0030.08020.08
7.0.20.0070.04720.05
7.0.10.0070.08320.09
7.0.00.0100.06019.95
5.6.280.0100.07020.88
5.6.240.0000.08720.61
5.6.230.0230.05320.67
5.6.220.0100.08020.67
5.6.210.0100.08020.75
5.6.200.0100.05021.09
5.6.190.0100.08020.95
5.6.180.0070.08321.14
5.6.170.0200.04721.04
5.6.160.0070.04321.09
5.6.150.0100.08021.05
5.6.140.0100.06021.05
5.6.130.0070.08321.11
5.6.120.0130.07720.95
5.6.110.0030.08021.08
5.6.100.0200.05721.02
5.6.90.0070.05020.94
5.6.80.0070.07020.35
5.6.70.0130.07720.49
5.6.60.0130.07020.46
5.6.50.0100.08020.43
5.6.40.0130.07020.40
5.6.30.0130.05020.47
5.6.20.0030.07720.36
5.6.10.0070.05020.42
5.6.00.0130.07020.42
5.5.380.0070.06320.45
5.5.370.0000.05020.38
5.5.360.0130.08720.35
5.5.350.0070.04720.35
5.5.340.0070.08020.81
5.5.330.0130.06720.89
5.5.320.0030.06020.86
5.5.310.0100.07720.80
5.5.300.0130.05320.73
5.5.290.0100.08020.89
5.5.280.0070.08320.80
5.5.270.0070.07020.87
5.5.260.0030.06720.87
5.5.250.0070.07720.68
5.5.240.0100.04320.29
5.5.230.0100.07320.03
5.5.220.0100.07320.18
5.5.210.0130.06020.12
5.5.200.0130.05320.28
5.5.190.0000.05320.00
5.5.180.0070.04720.23
5.5.160.0130.04020.00
5.5.150.0030.08020.18
5.5.140.0100.05020.22
5.5.130.0100.04720.28
5.5.120.0100.03720.23
5.5.110.0100.05320.10
5.5.100.0030.04720.18
5.5.90.0000.08320.11
5.5.80.0100.07720.14
5.5.70.0100.05720.06
5.5.60.0070.04720.06
5.5.50.0030.08019.95
5.5.40.0100.07720.14
5.5.30.0230.06319.96
5.5.20.0070.07720.04
5.5.10.0000.08720.04
5.5.00.0030.06020.07

preferences:
40.54 ms | 403 KiB | 5 Q