3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$xml = simplexml_load_file('data.xml'); $xml = simplexml_load_string('<items> <item> <images> <image>A</image> <image>B</image> <image>C</image> </images> </item> </items>'); //var_dump($xml); // Loop over items in original xml foreach ($xml->item as $item) { if ($item->images->image->count() > 1) { // Clone entry $images = clone $item->images; // Remove entry and replace with empty unset($item->images); $item->addChild('images'); foreach ($images->image as $key => $img ) { $name = 'image' . ($key) ?: ''; $item>images->addChild($name, $img); } } } //$xml->asXML('POTO.xml'); echo $xml->asXML();
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/6YhfG on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/6YhfG on line 27
Process exited with code 255.