3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = new SimpleXMLElement('<root><elements attr="test"><el>test1</el><el>test2</el><el test_attr="123">test3</el></elements></root>'); //print_r(json_decode(json_encode((array) simplexml_load_string($xml)), 1)); function xml2array ( xml, $out = array () ) { foreach ( (array) $xmlObject as $index => $node ) $out[$index] = ( is_object ( $node ) ) ? xml2array ( $node ) : $node; return $out; } print_r(xml2array($xml));
Output for 5.4.0 - 5.4.19, 5.5.0 - 5.5.3
Parse error: syntax error, unexpected ',', expecting '&' or variable (T_VARIABLE) in /in/PoDph on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected ',', expecting '&' or T_VARIABLE in /in/PoDph on line 6
Process exited with code 255.

preferences:
181.65 ms | 1395 KiB | 59 Q