3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <response> <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">10</int> <lst name="params"> <str name="q">*:*</str> <str name="facet.field">main</str> <str name="facet.mincount">1</str> <str name="rows">0</str> <str name="facet">on</str> </lst> </lst> <lst name="responseHeader"> <int name="status">1</int> <int name="QTime">11</int> <lst name="params"> <str name="q">*:*</str> <str name="facet.field">main</str> <str name="facet.mincount">1</str> <str name="rows">0</str> <str name="facet">on</str> </lst> </lst> <result name="response" numFound="5473" start="0"/> <lst name="facet_counts"> <lst name="facet_queries"/> <lst name="facet_fields"> <lst name="main"> <int name="Victoria University Photograph Collection">1693</int> </lst> </lst> </lst> </response> XML; $input = simplexml_load_string($xml); $items = $input->xpath('/response/lst//*'); $arr = []; foreach ($items as $item) { if (isset($item->attributes()->name) && trim((string)$item) !== "") { $arr[] = [(string)$item->attributes()->name => (string)$item]; } } print_r($arr);
Output for 5.6.38, 7.1.0 - 7.1.22, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Array ( [0] => Array ( [status] => 0 ) [1] => Array ( [QTime] => 10 ) [2] => Array ( [q] => *:* ) [3] => Array ( [facet.field] => main ) [4] => Array ( [facet.mincount] => 1 ) [5] => Array ( [rows] => 0 ) [6] => Array ( [facet] => on ) [7] => Array ( [status] => 1 ) [8] => Array ( [QTime] => 11 ) [9] => Array ( [q] => *:* ) [10] => Array ( [facet.field] => main ) [11] => Array ( [facet.mincount] => 1 ) [12] => Array ( [rows] => 0 ) [13] => Array ( [facet] => on ) [14] => Array ( [Victoria University Photograph Collection] => 1693 ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
193.34 ms | 408 KiB | 5 Q