3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlstr = '<?xml version="1.0" encoding="utf-8"?> <root total="450" count="4" start="0"> <Code>0</Code> <Item><Person.P_Id>14845</Person.P_Id></Item> <Item><Person.P_Id>14844</Person.P_Id></Item> <Item><Person.P_Id>14837</Person.P_Id></Item> <Item><Person.P_Id>14836</Person.P_Id></Item> </root>'; $xml = simplexml_load_string($xmlstr); $itemobjs = $xml->xpath('//Item'); print_r($itemobjs); $items = array_map(function ($v) { return (string)$v->{'Person.P_Id'}; }, $itemobjs); print_r($items);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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.27, 8.4.1 - 8.4.14
Array ( [0] => SimpleXMLElement Object ( [Person.P_Id] => 14845 ) [1] => SimpleXMLElement Object ( [Person.P_Id] => 14844 ) [2] => SimpleXMLElement Object ( [Person.P_Id] => 14837 ) [3] => SimpleXMLElement Object ( [Person.P_Id] => 14836 ) ) Array ( [0] => 14845 [1] => 14844 [2] => 14837 [3] => 14836 )

preferences:
190.25 ms | 409 KiB | 5 Q