3v4l.org

run code in 300+ PHP versions simultaneously
<?php // First of all, I've added <root> element to your XML document, // because otherwise it's invalid. // But it's not important for the rest of the code. // // Also I've added additional <somethingelse> tag to show that filtering is working $xmlString = '<root><details> <name>name1</name> <address>address1</address> </details> <details> <name>name2</name> <mobile>mobileNum</mobile> <address>address2</address> <somethingelse>This will be filtered</somethingelse> </details></root>'; $xml = new SimpleXMLElement($xmlString); //array_flip to get node names as keys for later foreach loop $nodes = array_flip(array ( 'person_name' => 'name', 'mobile_no' => 'mobile', 'address' => 'address', )); $final_data = array(); //Here are all <details> sections' data in array. $node_values = $xml->xpath('//details'); $node_values = json_decode(json_encode((array)$node_values), TRUE); //this loop filters XML data from keys not existing in $nodes, which are the only that you want to keep foreach($node_values as $node) { $final_data[] = array_intersect_key($node, $nodes); } var_dump($final_data);

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.130.0080.00018.82
8.3.120.0060.00321.12
8.3.110.0080.00018.81
8.3.100.0030.00516.91
8.3.90.0040.00426.77
8.3.80.0090.00017.00
8.3.70.0150.00018.80
8.3.60.0130.00716.88
8.3.50.0130.00821.26
8.3.40.0110.00718.95
8.3.30.0000.01519.15
8.3.20.0000.00820.06
8.3.10.0090.00020.68
8.3.00.0040.00424.21
8.2.250.0150.00617.08
8.2.240.0120.00617.68
8.2.230.0000.00820.94
8.2.220.0090.00024.06
8.2.210.0130.00726.77
8.2.200.0100.00016.74
8.2.190.0080.00817.00
8.2.180.0070.01418.79
8.2.170.0040.01122.96
8.2.160.0110.00720.76
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0030.00620.76
8.2.120.0040.00426.16
8.2.110.0080.00321.27
8.2.100.0000.01318.16
8.2.90.0090.00018.28
8.2.80.0040.00419.48
8.2.70.0040.00418.13
8.2.60.0000.00818.00
8.2.50.0000.00818.30
8.2.40.0050.00318.41
8.2.30.0040.00420.75
8.2.20.0000.00718.53
8.2.10.0040.00418.48
8.2.00.0070.00018.61
8.1.300.0100.00720.46
8.1.290.0040.00430.84
8.1.280.0070.00725.92
8.1.270.0090.00021.16
8.1.260.0070.00026.35
8.1.250.0030.00528.09
8.1.240.0100.00022.58
8.1.230.0080.00421.38
8.1.220.0000.00818.13
8.1.210.0060.00319.08
8.1.200.0060.00317.60
8.1.190.0040.00417.75
8.1.180.0090.00018.10
8.1.170.0030.00517.95
8.1.160.0030.00519.23
8.1.150.0000.00720.65
8.1.140.0030.00619.91
8.1.130.0030.00319.31
8.1.120.0040.00417.86
8.1.110.0000.00817.85
8.1.100.0050.00217.85
8.1.90.0000.00817.77
8.1.80.0040.00417.72
8.1.70.0030.00317.86
8.1.60.0040.00517.80
8.1.50.0050.00317.71
8.1.40.0040.00417.94
8.1.30.0030.00618.08
8.1.20.0000.00817.97
8.1.10.0080.00017.95
8.1.00.0000.00717.75
8.0.300.0040.00420.32
8.0.290.0000.00717.13
8.0.280.0030.00318.74
8.0.270.0000.00817.20
8.0.260.0050.00317.59
8.0.250.0000.00817.34
8.0.240.0030.00517.38
8.0.230.0070.00017.36
8.0.220.0070.00017.21
8.0.210.0000.00717.34
8.0.200.0000.00617.25
8.0.190.0000.00817.35
8.0.180.0020.00817.36
8.0.170.0040.00417.13
8.0.160.0040.00417.11
8.0.150.0040.00417.16
8.0.140.0020.00517.07
8.0.130.0030.00313.62
8.0.120.0040.00417.21
8.0.110.0040.00417.13
8.0.100.0040.00417.27
8.0.90.0000.00717.21
8.0.80.0060.01017.24
8.0.70.0070.00017.30
8.0.60.0000.00817.13
8.0.50.0050.00217.28
8.0.30.0090.01217.53
8.0.20.0100.01017.48
8.0.10.0000.00817.29
8.0.00.0140.01017.17
7.4.330.0050.00015.55
7.4.320.0030.00316.81
7.4.300.0000.00616.89
7.4.290.0070.00316.78
7.4.280.0000.00816.98
7.4.270.0030.00316.82
7.4.260.0070.00417.00
7.4.250.0030.00316.91
7.4.240.0070.00016.84
7.4.230.0040.00416.76
7.4.220.0110.00816.86
7.4.210.0050.01016.85
7.4.200.0040.00416.96
7.4.160.0050.01216.78
7.4.150.0110.00717.40
7.4.140.0090.01117.86
7.4.130.0120.00816.94
7.4.120.0100.01116.85
7.4.110.0090.00916.99
7.4.100.0100.01016.77
7.4.90.0150.00316.86
7.4.80.0120.00619.39
7.4.70.0090.00916.82
7.4.60.0120.00316.71
7.4.50.0100.00716.75
7.4.40.0050.01416.89
7.4.30.0100.00716.65
7.4.00.0110.00415.36
7.3.330.0000.00613.41
7.3.320.0030.00313.52
7.3.310.0030.00516.73
7.3.300.0000.00716.60
7.3.290.0070.00016.57
7.3.280.0070.01116.64
7.3.270.0120.00617.40
7.3.260.0120.01216.74
7.3.250.0100.00916.79
7.3.240.0130.00517.02
7.3.230.0110.00516.58
7.3.210.0070.01116.68
7.3.200.0080.00816.68
7.3.190.0100.00716.88
7.3.180.0140.00316.59
7.3.170.0160.00016.71
7.3.160.0060.01216.75
7.2.330.0000.01917.11
7.2.320.0120.01217.13
7.2.310.0070.01116.89
7.2.300.0170.00716.97
7.2.290.0100.01016.83
7.1.70.0030.00717.43
7.1.60.0100.00717.43
7.1.20.0270.05740.35
7.1.10.0100.06722.38
7.1.00.0070.06022.48
7.0.200.0000.00717.13
7.0.160.0100.06721.98
7.0.150.0100.05021.96
7.0.140.0030.05722.05
7.0.130.0000.06322.03
7.0.120.0100.06022.00
7.0.110.0100.05322.14
7.0.100.0130.04722.02
7.0.90.0070.05722.31
7.0.80.0130.05322.01
7.0.70.0100.05322.09
7.0.60.0130.05022.15
7.0.50.0070.05722.02
7.0.40.0130.04722.10
7.0.30.0030.06322.19
7.0.20.0070.06022.30
7.0.10.0070.05322.10
7.0.00.0100.05722.03

preferences:
29.47 ms | 403 KiB | 5 Q