3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pathify($array, $path, &$output = []){ // declare $output as an empty array by default and modify by reference foreach($array as $k => $v){ if (is_array($v)) { // if can recurse pathify($v, "$path/$k", $output); // append key to path, access $v array }else{ $output[] = "$path/$k - $v"; // push completed string to output array } } return $output; // return array of path strings } $json='{ "name":{ "first_name":"James", "last_name":"Bond" }, "aliases":["007","Bond"], "profiles":[{"0":"unknown"},"007",{"2":"secret agent"}] }'; $data = json_decode($json, true); // decode json to an array echo implode("\n", pathify($data, "/Bond1")); // separate the returned string with a newline echo "\n-------\n"; echo implode("\n", pathify([], "/Bond2")); // separate the returned string with a newline echo "\n-------\n"; echo implode("\n", pathify([], "/Bond3")); // separate the returned string with a newline echo "\n-------\n"; echo implode("\n", pathify($data, "/Bond4")); // separate the returned string with a newline echo "\n-------\n"; echo implode("\n", pathify($data, "/Bond5")); // separate the returned string with a newline

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.0090.00816.55
8.5.00.0110.01220.02
8.4.150.0010.00214.05
8.4.140.0150.00617.50
8.4.130.0120.00918.02
8.4.120.0120.00820.67
8.4.110.0100.01022.72
8.4.100.0040.00517.75
8.4.90.0120.00817.66
8.4.80.0080.00717.69
8.4.70.0100.01118.09
8.4.60.0140.00318.39
8.4.50.0140.00619.37
8.4.40.0060.00317.71
8.4.30.0070.01319.49
8.4.20.0100.01019.33
8.4.10.0090.00017.60
8.3.280.0110.00918.41
8.3.270.0130.00616.49
8.3.260.0140.00516.73
8.3.250.0030.00518.93
8.3.240.0140.00716.52
8.3.230.0100.00916.76
8.3.220.0040.00417.29
8.3.210.0080.01116.77
8.3.200.0110.00816.48
8.3.190.0120.00316.89
8.3.180.0100.00516.66
8.3.170.0040.00418.92
8.3.160.0100.01016.63
8.3.150.0000.00718.97
8.3.140.0000.01016.65
8.3.130.0030.00618.61
8.3.120.0080.00820.64
8.3.110.0120.00420.94
8.3.100.0060.00324.06
8.3.90.0150.00426.77
8.3.80.0090.00018.30
8.3.70.0090.00916.61
8.3.60.0070.00718.43
8.3.50.0070.00917.91
8.3.40.0040.01218.57
8.3.30.0110.00418.71
8.3.20.0080.00021.88
8.3.10.0080.00023.66
8.3.00.0070.00023.67
8.2.290.0090.00720.34
8.2.280.0090.00919.97
8.2.270.0040.00418.74
8.2.260.0140.00319.00
8.2.250.0090.00018.42
8.2.240.0090.00017.16
8.2.230.0060.00322.58
8.2.220.0070.00337.54
8.2.210.0000.00726.77
8.2.200.0060.00316.63
8.2.190.0140.00316.58
8.2.180.0110.00718.13
8.2.170.0110.00419.13
8.2.160.0060.01022.96
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0050.00321.11
8.2.120.0000.00726.35
8.2.110.0000.00920.93
8.2.100.0040.00717.78
8.2.90.0000.00819.25
8.2.80.0000.00917.97
8.2.70.0070.00317.63
8.2.60.0050.00317.93
8.2.50.0050.00318.07
8.2.40.0040.00418.03
8.2.30.0060.00318.08
8.2.20.0040.00418.07
8.2.10.0040.00418.11
8.2.00.0090.00018.18
8.1.330.0090.00918.27
8.1.320.0130.00716.13
8.1.310.0100.01016.36
8.1.300.0100.00718.52
8.1.290.0040.00818.88
8.1.280.0100.00325.92
8.1.270.0050.00223.88
8.1.260.0000.00726.35
8.1.250.0000.00828.09
8.1.240.0030.00620.86
8.1.230.0040.00722.11
8.1.220.0080.00017.74
8.1.210.0060.00318.77
8.1.200.0060.00317.23
8.1.190.0000.00817.23
8.1.180.0040.00418.10
8.1.170.0060.00318.59
8.1.160.0000.00818.90
8.1.150.0070.00020.84
8.1.140.0030.00517.72
8.1.130.0000.00818.95
8.1.120.0040.00417.40
8.1.110.0070.00417.52
8.1.100.0060.00317.47
8.1.90.0090.00017.46
8.1.80.0040.00417.44
8.1.70.0050.00317.49
8.1.60.0060.00617.63
8.1.50.0030.00617.43
8.1.40.0080.00017.50
8.1.30.0040.00417.66
8.1.20.0000.00717.55
8.1.10.0080.00017.55
8.1.00.0030.00617.29
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0040.00418.46
8.0.270.0070.00017.27
8.0.260.0000.00617.34
8.0.250.0040.00416.97
8.0.240.0000.00716.86
8.0.230.0000.00616.96
8.0.220.0100.00016.90
8.0.210.0030.00316.88
8.0.200.0000.00916.88
8.0.190.0000.00717.00
8.0.180.0000.00716.93
8.0.170.0030.00516.89
8.0.160.0000.00716.93
8.0.150.0020.00516.76
8.0.140.0050.00216.89
8.0.130.0050.00013.29
8.0.120.0080.00016.80
8.0.110.0000.00716.93
8.0.100.0080.00016.89
8.0.90.0000.00816.93
8.0.80.0040.01116.89
8.0.70.0040.00416.73
8.0.60.0000.00816.93
8.0.50.0000.00716.78
8.0.30.0100.00916.89
8.0.20.0190.00517.41
8.0.10.0000.00716.98
8.0.00.0110.00616.80
7.4.330.0000.00415.55
7.4.320.0000.00616.66
7.4.300.0000.00716.42
7.4.290.0070.00416.52
7.4.280.0000.00716.57
7.4.270.0100.00016.39
7.4.260.0000.00716.61
7.4.250.0030.00316.56
7.4.240.0070.00016.47
7.4.230.0040.00416.60
7.4.220.0000.00816.64
7.4.210.0090.00516.58
7.4.200.0030.00316.63
7.4.160.0050.01016.49
7.4.140.0090.01117.86
7.4.130.0090.01316.66
7.4.120.0130.00616.52
7.4.110.0040.01316.32
7.4.100.0120.00616.56
7.4.90.0110.00816.54
7.4.80.0060.01219.39
7.4.70.0140.00316.54
7.4.60.0120.00616.49
7.4.50.0160.00016.72
7.4.40.0090.00816.48
7.4.00.0040.00815.05
7.3.330.0000.00513.34
7.3.320.0000.00613.36
7.3.310.0070.00016.24
7.3.300.0040.00416.36
7.3.290.0040.00416.32
7.3.280.0100.00816.39
7.3.260.0120.00816.51
7.3.240.0100.00816.43
7.3.230.0170.00316.36
7.3.210.0100.00716.56
7.3.200.0150.00416.51
7.3.190.0110.00616.46
7.3.180.0100.00716.54
7.3.170.0030.01316.61
7.3.160.0040.01316.27
7.3.70.0060.00914.85
7.3.60.0070.00714.77
7.3.50.0040.00714.72
7.3.40.0060.00614.80
7.3.30.0040.00714.95
7.3.20.0150.00014.50
7.3.10.0110.00515.67
7.3.00.0130.00415.90
7.2.330.0090.00916.70
7.2.320.0090.00916.80
7.2.310.0090.00916.52
7.2.300.0090.00916.78
7.2.290.0030.01516.73
7.2.200.0060.00615.17
7.2.190.0110.00314.82
7.2.180.0030.01015.12
7.2.170.0140.01115.13
7.2.160.0070.01415.20
7.2.150.0140.01014.98
7.2.140.0180.01015.28
7.2.130.0100.00815.89
7.2.120.0130.00815.98
7.2.110.0110.00816.14
7.2.100.0110.00516.04
7.2.90.0090.00616.06
7.2.80.0100.01016.07
7.2.70.0060.00915.66
7.2.60.0090.00516.25
7.2.50.0130.00815.99
7.2.40.0960.01016.63
7.2.30.1390.01016.69
7.2.20.1190.01016.69
7.2.10.1220.01116.57
7.2.00.0830.01016.76
7.1.300.0090.00614.12
7.1.290.0170.00714.09
7.1.280.0070.00714.16
7.1.270.0110.00414.06
7.1.260.0160.01013.82
7.1.250.0120.00514.78
7.1.240.0260.00914.14
7.1.230.0410.01514.12
7.1.220.0230.00013.83
7.1.210.0310.00413.98
7.1.200.0080.00814.82
7.1.190.0250.00614.09
7.1.180.0190.00813.82
7.1.170.0890.00613.88
7.1.160.1470.01015.32
7.1.150.1500.00815.42
7.1.140.1380.01015.43
7.1.130.1710.01015.54
7.1.120.1520.01115.35
7.1.110.1590.01115.12
7.1.100.2260.01215.25
7.1.90.1570.00914.96
7.1.80.1810.00614.99
7.1.70.1620.00814.53
7.1.60.1920.01123.81
7.1.50.1790.01623.49
7.1.40.2230.01323.26
7.1.30.2800.01323.38
7.1.20.2560.00923.34
7.1.10.2230.00714.39
7.1.00.1890.01014.43
7.0.330.0150.01513.46
5.6.400.0110.00413.97
5.6.390.0200.00814.76
5.6.380.0110.01514.35

preferences:
163.39 ms | 403 KiB | 5 Q