3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<EOD [ { "id": "3", "type": "default", "place": "1" }, { "id": "3", "type": "default", "place": "2" }, { "id": "3", "type": "default", "place": "3" } ] EOD; $array = json_decode($json, true); // Here is trick; get the key of the array using array_column $key = array_search('2', array_column($array, 'place')); // If any key found modify the array if ($key && array_key_exists($key, $array)) { $array[$key] = [ 'id' => 7, 'type' => 1, 'place' => 2, 'description' => 'This is item place 2', 'image' => 'this_is_the_image.png', ]; } print_r($array);

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.4.130.0050.00418.96
8.4.120.0130.00818.90
8.4.110.0100.01022.58
8.4.100.0130.00917.91
8.4.90.0120.00820.60
8.4.80.0130.00718.82
8.4.70.0100.01019.14
8.4.60.0080.01320.34
8.4.50.0100.00618.80
8.4.40.0060.00317.62
8.4.30.0130.00618.64
8.4.20.0030.01620.57
8.4.10.0060.00317.59
8.3.260.0080.01116.74
8.3.250.0100.00816.85
8.3.240.0100.00916.73
8.3.230.0060.00316.56
8.3.220.0110.00818.80
8.3.210.0110.00516.53
8.3.200.0080.00116.63
8.3.190.0100.00818.95
8.3.180.0060.01018.88
8.3.170.0120.00618.62
8.3.160.0160.00316.43
8.3.150.0160.00417.34
8.3.140.0090.00916.69
8.3.130.0120.00616.53
8.3.120.0000.00920.55
8.3.110.0120.00420.94
8.3.100.0000.00924.06
8.3.90.0080.00526.77
8.3.80.0030.00616.50
8.3.70.0100.01016.71
8.3.60.0040.01418.68
8.3.50.0100.00623.80
8.3.40.0030.01618.77
8.3.30.0110.00318.88
8.3.20.0040.00420.82
8.3.10.0040.00420.20
8.3.00.0060.00320.68
8.2.290.0130.00716.63
8.2.280.0090.00918.30
8.2.270.0090.00917.14
8.2.260.0140.00318.77
8.2.250.0060.00316.88
8.2.240.0040.00417.26
8.2.230.0030.00622.58
8.2.220.0060.01337.54
8.2.210.0160.00326.77
8.2.200.0110.00016.63
8.2.190.0110.01116.58
8.2.180.0140.00318.41
8.2.170.0160.00022.96
8.2.160.0110.00322.26
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0080.00021.05
8.2.110.0030.00622.12
8.2.100.0040.00717.91
8.2.90.0000.00917.63
8.2.80.0040.00418.92
8.2.70.0040.00417.50
8.2.60.0040.00417.63
8.2.50.0030.00519.34
8.2.40.0050.00521.19
8.2.30.0000.00819.34
8.2.20.0020.00518.01
8.2.10.0030.00519.20
8.2.00.0040.00419.36
8.1.330.0100.00816.31
8.1.320.0160.00317.94
8.1.310.0120.00316.51
8.1.300.0060.00316.22
8.1.290.0030.00718.88
8.1.280.0060.00925.92
8.1.270.0070.00022.07
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0100.00023.84
8.1.230.0110.00019.08
8.1.220.0040.00417.76
8.1.210.0000.00818.77
8.1.200.0000.00917.38
8.1.190.0060.00317.36
8.1.180.0040.00419.02
8.1.170.0030.00618.53
8.1.160.0070.00019.08
8.1.150.0040.00418.81
8.1.140.0000.00718.85
8.1.130.0040.00417.33
8.1.120.0000.00717.52
8.1.110.0050.00317.46
8.1.100.0040.00417.48
8.1.90.0040.00417.36
8.1.80.0000.00817.36
8.1.70.0050.00217.39
8.1.60.0060.00617.60
8.1.50.0060.00317.55
8.1.40.0040.00417.47
8.1.30.0000.00717.61
8.1.20.0000.00817.64
8.1.10.0000.00717.45
8.1.00.0000.00817.47
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00718.46
8.0.270.0070.00016.89
8.0.260.0070.00016.89
8.0.250.0000.00717.00
8.0.240.0060.00017.07
8.0.230.0030.00317.04
8.0.220.0030.00316.84
8.0.210.0030.00316.97
8.0.200.0000.00716.89
8.0.190.0020.00517.01
8.0.180.0030.00517.01
8.0.170.0000.00916.96
8.0.160.0000.01016.99
8.0.150.0040.00316.91
8.0.140.0100.00016.93
8.0.130.0000.00613.46
8.0.120.0030.00517.04
8.0.110.0070.00017.01
8.0.100.0090.00016.84
8.0.90.0060.00316.91
8.0.80.0060.01116.95
8.0.70.0070.00016.84
8.0.60.0000.00716.94
8.0.50.0030.00517.03
8.0.30.0090.01517.21
8.0.20.0150.00817.17
8.0.10.0000.00717.02
8.0.00.0100.01416.53
7.4.330.0050.00015.55
7.4.320.0030.00316.61
7.4.300.0050.00316.57
7.4.290.0030.00316.61
7.4.280.0080.00316.43
7.4.270.0070.00216.65
7.4.260.0040.00413.32
7.4.250.0000.00716.55
7.4.240.0020.00616.52
7.4.230.0040.00416.39
7.4.220.0000.00716.48
7.4.210.0100.00516.57
7.4.200.0030.00316.68
7.4.130.0080.00916.57
7.4.120.0120.00916.46
7.4.110.0060.01016.54
7.4.100.0110.00716.55
7.4.90.0130.00616.58
7.4.80.0090.01019.39
7.4.70.0150.00416.38
7.4.60.0100.00616.45
7.4.50.0000.01116.66
7.4.40.0100.01216.71
7.4.30.0060.01716.41
7.4.20.0120.00716.32
7.4.10.0130.00316.45
7.4.00.0100.01116.38
7.3.330.0000.00716.27
7.3.320.0000.00513.30
7.3.310.0000.00716.27
7.3.300.0030.00316.23
7.3.290.0080.00716.31
7.3.260.0090.01216.48
7.3.240.0090.00816.41
7.3.230.0140.00516.36
7.3.210.0060.01216.40
7.3.200.0160.00016.36
7.3.190.0170.00016.45
7.3.180.0040.01216.39
7.3.170.0110.01116.54
7.3.160.0060.01316.37
7.3.150.0040.01316.54
7.3.140.0070.01016.45
7.3.130.0030.01716.36
7.3.120.0060.01616.27
7.3.110.0090.00916.31
7.3.100.0030.01316.41
7.3.90.0060.01016.31
7.3.80.0080.00816.45
7.3.70.0130.01016.27
7.3.60.0060.01516.33
7.3.50.0060.01616.36
7.3.40.0120.00316.31
7.3.30.0100.00716.34
7.3.20.0070.01016.14
7.3.10.0100.01016.36
7.3.00.0100.00616.34
7.2.330.0060.01316.38
7.2.320.0140.00316.63
7.2.310.0080.00816.73
7.2.300.0140.00416.61
7.2.290.0000.01516.76
7.2.280.0140.00916.64
7.2.270.0070.01016.48
7.2.260.0120.00916.43
7.2.250.0060.01016.38
7.2.240.0060.00916.67
7.2.230.0120.00316.42
7.2.220.0110.00616.47
7.2.210.0120.00316.66
7.2.200.0130.01016.40
7.2.190.0070.01716.34
7.2.180.0090.01216.49
7.2.170.0090.00616.39
7.2.160.0070.01016.55
7.2.150.0100.00716.40
7.2.140.0060.00916.59
7.2.130.0030.01216.50
7.2.120.0130.00316.47
7.2.110.0050.01016.54
7.2.100.0060.00916.53
7.2.90.0090.00616.43
7.2.80.0000.01516.50
7.2.70.0100.01016.53
7.2.60.0100.00616.54
7.2.50.0140.00316.50
7.2.40.0000.01616.45
7.2.30.0170.00316.41
7.2.20.0080.01516.65
7.2.10.0200.00316.36
7.2.00.0100.01316.52

preferences:
32.33 ms | 403 KiB | 5 Q