3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = new SimpleXMLElement( '<catalogo> <server> <nome>ltw1319</nome> <convenzione>comprato</convenzione> <interoperabilita>Aggregato</interoperabilita> <url>http://ltw1319.web.cs.unibo.it/richieste</url> </server> <server> <nome>ltw1330</nome> <convenzione>comprato</convenzione> <interoperabilita>Aggregato</interoperabilita> <url>http://ltw1330.web.cs.unibo.it/richieste</url> </server> <server> <nome>ltw1336</nome> <convenzione>comprato</convenzione> <interoperabilita>Aggregato</interoperabilita> <url>http://ltw1336.web.cs.unibo.it/richieste</url> </server> <server> <nome>ltw1311</nome> <convenzione>Integrato</convenzione> <interoperabilita>Aggregato</interoperabilita> <url>http://ltw1311.web.cs.unibo.it/richieste</url> </server> </catalogo> '); $ulrscomprati = array(); $xml = simplexml_load_file('server.xml'); $item = $xml->server; $count=0; foreach($item as $dati){ $ur=$dati->url; if($ur != ""){ $ulrscomprati[$count]=$ur; } $count=$count+1; } echo $ulrscomprati[$count]; $result_from_server = json_encode($ulrscomprati,$data); echo $result_from_server;
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: simplexml_load_file(): I/O warning : failed to load external entity "server.xml" in /in/EFKlb on line 33 Notice: Trying to get property of non-object in /in/EFKlb on line 34 Warning: Invalid argument supplied for foreach() in /in/EFKlb on line 36 Notice: Undefined offset: 0 in /in/EFKlb on line 43 Notice: Undefined variable: data in /in/EFKlb on line 44 []
Output for hhvm-3.10.0 - 3.12.0
Warning: No such file or directory in /in/EFKlb on line 33 Notice: Cannot access property on non-object in /in/EFKlb on line 34 Warning: Invalid argument supplied for foreach() in /in/EFKlb on line 42 Notice: Undefined index: 0 in /in/EFKlb on line 43 Notice: Undefined variable: data in /in/EFKlb on line 44 []
Output for 5.2.0 - 5.2.17
Warning: simplexml_load_file(): I/O warning : failed to load external entity "server.xml" in /in/EFKlb on line 33 Notice: Trying to get property of non-object in /in/EFKlb on line 34 Warning: Invalid argument supplied for foreach() in /in/EFKlb on line 36 Notice: Undefined offset: 0 in /in/EFKlb on line 43 Notice: Undefined variable: data in /in/EFKlb on line 44 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/EFKlb on line 44
Output for 5.1.0 - 5.1.6
Warning: simplexml_load_file(): I/O warning : failed to load external entity "server.xml" in /in/EFKlb on line 33 Notice: Trying to get property of non-object in /in/EFKlb on line 34 Warning: Invalid argument supplied for foreach() in /in/EFKlb on line 36 Notice: Undefined offset: 0 in /in/EFKlb on line 43 Fatal error: Call to undefined function json_encode() in /in/EFKlb on line 44
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: I/O warning : failed to load external entity "server.xml" in /in/EFKlb on line 33 Notice: Trying to get property of non-object in /in/EFKlb on line 34 Warning: Invalid argument supplied for foreach() in /in/EFKlb on line 36 Notice: Undefined offset: 0 in /in/EFKlb on line 43 Fatal error: Call to undefined function json_encode() in /in/EFKlb on line 44
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/EFKlb on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/EFKlb on line 3