(after deleting an XML node) the following gets a list of <picture> 'id' attribute values:
$objXML = new SimpleXMLElement(XML_FILE_NAME, null, true);
$picture = $objXML->xpath('picture');
$arrayCurrent = array();
foreach($picture as $value) {
$arrayCurrent[] = (string)$value['id'];
}
sort($arrayCurrent); // required as XML nodes not in numerical 'id' order
print_r($arrayCurrent);
Which returns the following:
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 5 [5] => 6 [6] => 7 [7] => 8 )
I want to set each id to the value of its current key like so:
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 )
I've been messing about with this for a while but I wondered if there is a simple way to achieve this?