3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * How to get attribute of node with namespace using SimpleXML? * * @link http://stackoverflow.com/q/6576773/367456 */ $buffer = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:x-trumba="http://schemas.trumba.com/rss/x-trumba"> <entry> <yt:duration seconds="105">test</yt:duration> <yt:duration seconds="1870">test</yt:duration> <x-trumba:customfield name="Event Type" id="21" type="number">Sound Publishing Event</x-trumba:customfield> <x-trumba:customfield name="Category" id="25674" type="text">Family</x-trumba:customfield> </entry> </feed>'; $xml = new SimpleXMLElement($buffer); foreach ($xml->entry as $item) { //original comment: how to get seconds? $namespaces = $item->getNameSpaces(true); $yt = $item->children($namespaces['yt']); $trumba = $item->children($namespaces['x-trumba']); $seconds = $yt->duration->attributes(); echo $seconds['seconds'], "\n"; // original comment: but doesn't work. $numofItems = $trumba->customfield->count(); foreach ($item->children('x-trumba', TRUE) as $child) { //echo $child->asXML(); //echo $child->attributes('id')); echo $child->attributes('x-trumba', TRUE)->Name; } foreach ($trumba->customfield as $custom) { $name = $trumba->customfield->attributes(); // var_dump($custom); } }

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.0070.01416.73
8.3.50.0170.00318.21
8.3.40.0060.00918.93
8.3.30.0090.00618.88
8.3.20.0040.00418.82
8.3.10.0040.00422.07
8.3.00.0060.00322.15
8.2.180.0070.01418.34
8.2.170.0110.00722.96
8.2.160.0100.00322.46
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00420.02
8.2.120.0040.00426.35
8.2.110.0030.00719.57
8.2.100.0060.00619.91
8.2.90.0050.00319.37
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0000.00818.18
8.2.50.0090.00318.10
8.2.40.0040.00420.80
8.2.30.0030.00521.25
8.2.20.0050.00218.46
8.2.10.0040.00418.31
8.2.00.0000.00717.99
8.1.280.0120.00325.92
8.1.270.0040.00424.07
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00621.62
8.1.230.0100.00018.07
8.1.220.0050.00317.91
8.1.210.0080.00018.77
8.1.200.0030.00717.60
8.1.190.0050.00317.35
8.1.180.0080.00018.10
8.1.170.0080.00018.74
8.1.160.0000.00722.29
8.1.150.0000.00720.52
8.1.140.0040.00419.81
8.1.130.0030.00317.82
8.1.120.0000.00717.60
8.1.110.0040.00417.73
8.1.100.0070.00017.58
8.1.90.0050.00317.69
8.1.80.0000.00717.67
8.1.70.0030.00317.64
8.1.60.0040.00417.87
8.1.50.0040.00417.67
8.1.40.0030.00517.61
8.1.30.0000.00817.75
8.1.20.0000.00717.73
8.1.10.0040.00417.66
8.1.00.0060.00317.60
8.0.300.0060.00318.77
8.0.290.0040.00416.75
8.0.280.0000.00718.74
8.0.270.0070.00017.53
8.0.260.0000.00817.48
8.0.250.0040.00417.25
8.0.240.0030.00317.11
8.0.230.0000.00917.14
8.0.220.0000.00717.07
8.0.210.0000.00717.02
8.0.200.0030.00317.23
8.0.190.0030.00417.19
8.0.180.0050.00217.03
8.0.170.0090.00017.17
8.0.160.0070.00017.21
8.0.150.0040.00417.01
8.0.140.0060.00317.04
8.0.130.0050.00013.58
8.0.120.0030.00616.98
8.0.110.0040.00417.05
8.0.100.0030.00617.05
8.0.90.0070.00017.12
8.0.80.0000.01517.14
8.0.70.0000.00716.94
8.0.60.0000.00716.99
8.0.50.0030.00517.23
8.0.30.0090.00917.37
8.0.20.0140.00617.40
8.0.10.0050.00317.19
8.0.00.0070.01016.89
7.4.330.0000.00515.55
7.4.320.0000.00816.79
7.4.300.0030.00316.73
7.4.290.0030.00316.74
7.4.280.0050.00316.70
7.4.270.0040.00416.72
7.4.260.0030.00316.74
7.4.250.0020.00516.74
7.4.240.0070.00016.91
7.4.230.0000.00716.68
7.4.220.0000.02416.62
7.4.210.0060.01516.87
7.4.200.0000.00716.82
7.4.160.0100.00616.76
7.4.150.0060.01017.40
7.4.140.0120.01117.86
7.4.130.0120.00616.68
7.4.120.0090.01016.79
7.4.110.0070.01416.66
7.4.100.0140.00716.77
7.4.90.0030.02416.87
7.4.80.0070.01019.39
7.4.70.0120.00816.84
7.4.60.0060.01216.69
7.4.50.0030.01016.84
7.4.40.0150.00616.76
7.4.30.0090.00916.43
7.4.10.0040.01515.39
7.4.00.0060.01015.11
7.3.330.0050.00013.18
7.3.320.0030.00313.38
7.3.310.0000.00716.56
7.3.300.0030.00316.49
7.3.290.0040.01416.52
7.3.280.0070.00916.49
7.3.270.0070.01017.40
7.3.260.0110.00816.72
7.3.250.0070.01016.57
7.3.240.0100.00916.61
7.3.230.0130.00316.52
7.3.210.0100.00716.46
7.3.200.0120.00416.47
7.3.190.0090.00916.53
7.3.180.0090.00616.48
7.3.170.0090.01516.75
7.3.160.0060.01116.53
7.3.130.0110.00714.88
7.3.120.0070.01014.76
7.3.110.0070.01114.75
7.3.100.0030.01314.75
7.3.90.0030.01414.74
7.3.80.0000.01314.96
7.3.70.0040.00714.73
7.3.60.0000.01614.70
7.3.50.0100.00914.91
7.3.40.0030.00614.62
7.3.30.0080.00814.64
7.3.20.0060.00916.63
7.3.10.0040.00816.80
7.3.00.0100.00316.77
7.2.330.0120.00616.91
7.2.320.0100.01616.67
7.2.310.0100.01016.75
7.2.300.0170.00317.04
7.2.290.0090.00916.89
7.2.260.0070.01114.93
7.2.250.0030.01515.24
7.2.240.0160.00015.24
7.2.230.0070.00715.16
7.2.220.0070.01015.18
7.2.210.0090.00615.30
7.2.200.0030.00615.17
7.2.190.0070.01015.19
7.2.180.0110.00414.85
7.2.170.0000.01114.79
7.2.160.0060.00915.24
7.2.150.0090.00616.90
7.2.140.0030.00716.93
7.2.130.0040.01216.85
7.2.120.0090.00617.10
7.2.110.0000.01317.30
7.2.100.0090.00617.11
7.2.90.0040.01117.22
7.2.80.0040.01217.07
7.2.70.0110.00016.77
7.2.60.0060.00917.18
7.2.50.0060.00617.36
7.2.40.0030.00617.19
7.2.30.0030.01017.20
7.2.20.0030.01017.11
7.2.10.0070.01017.12
7.2.00.0000.01317.00
7.1.330.0040.01415.70
7.1.320.0030.01015.73
7.1.310.0080.00615.84
7.1.300.0080.01115.59
7.1.290.0030.00916.10
7.1.280.0030.01015.77
7.1.270.0040.00715.90
7.1.260.0050.00515.79
7.1.250.0000.01315.76
7.1.240.0040.01215.91
7.1.230.0030.01115.85
7.1.220.0040.01215.65
7.1.210.0070.00715.88
7.1.200.0060.01015.85
7.1.190.0030.01315.74
7.1.180.0060.00915.92
7.1.170.0030.01015.53
7.1.160.0060.00815.87
7.1.150.0130.00315.85
7.1.140.0060.00615.90
7.1.130.0030.01015.88
7.1.120.0030.01215.95
7.1.110.0070.00715.98
7.1.100.0060.00615.82
7.1.90.0040.00715.71
7.1.80.0000.01315.77
7.1.70.0050.00516.39
7.1.60.0080.00616.52
7.1.50.0110.00415.86
7.1.40.0070.01115.77
7.1.30.0070.01115.79
7.1.20.0060.00615.83
7.1.10.0070.00715.93
7.1.00.0050.04219.23
7.0.330.0030.00615.48
7.0.320.0000.01415.58
7.0.310.0070.00715.50
7.0.300.0080.00415.62
7.0.290.0100.00315.45
7.0.280.0100.00315.43
7.0.270.0070.00715.42
7.0.260.0000.01315.68
7.0.250.0040.01115.62
7.0.240.0090.00315.61
7.0.230.0040.01115.55
7.0.220.0000.01415.61
7.0.210.0060.00815.48
7.0.200.0760.00615.25
7.0.190.0060.01015.57
7.0.180.0070.00715.47
7.0.170.0000.01415.41
7.0.160.0000.01315.74
7.0.150.0000.01215.66
7.0.140.0040.00415.69
7.0.130.0070.00715.48
7.0.120.0140.03518.69
7.0.110.0020.03618.84
7.0.100.0070.03718.95
7.0.90.0070.03318.81
7.0.80.0120.03018.81
7.0.70.0110.03318.79
7.0.60.0050.03318.68
7.0.50.0070.03018.89
7.0.40.0120.03718.03
7.0.30.0110.02918.00
7.0.20.0110.03318.03
7.0.10.0030.03518.03
7.0.00.0100.04018.04
5.6.400.0110.00014.73
5.6.390.0000.01114.61
5.6.380.0140.00314.56
5.6.370.0100.00614.47
5.6.360.0070.01014.75
5.6.350.0060.01014.52
5.6.340.0030.01214.90
5.6.330.0070.00714.30
5.6.320.0040.00714.55
5.6.310.0000.01614.06
5.6.300.0040.01114.68
5.6.290.0000.00814.68
5.6.280.0070.01014.45
5.6.270.0080.03117.78
5.6.260.0100.03017.82
5.6.250.0110.03017.73
5.6.240.0050.03017.79
5.6.230.0190.03317.86
5.6.220.0070.03817.79
5.6.210.0060.03317.65
5.6.200.0080.03017.66
5.6.190.0130.03317.67
5.6.180.0120.02817.79
5.6.170.0060.03317.62
5.6.160.0150.02817.77
5.6.150.0070.04117.75
5.6.140.0060.03417.70
5.6.130.0070.03317.83
5.6.120.0080.03217.80
5.6.110.0130.02817.80
5.6.100.0140.03717.63
5.6.90.0090.03317.80
5.6.80.0110.02617.26
5.6.70.0070.03317.33
5.6.60.0080.03117.31
5.6.50.0060.03317.47
5.6.40.0080.02817.36
5.6.30.0110.03217.36
5.6.20.0050.03317.62
5.6.10.0070.03717.21
5.6.00.0050.03417.38

preferences:
68.66 ms | 401 KiB | 5 Q