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(); $item = $xml->server; $count=0; foreach($item as $dati){ $ur=$dati->url; if($ur != ""){ $ulrscomprati[$count]=$ur; } $count=$count+1; } $ulrscomprati[$count]; $result_from_server = json_encode($ulrscomprati,$data); echo $result_from_server;
Output for 5.3.0 - 5.6.24, 7.0.0 - 7.1.0
Notice: Undefined offset: 4 in /in/9falD on line 42 Notice: Undefined variable: data in /in/9falD on line 43 [{"0":"http:\/\/ltw1319.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1330.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1336.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1311.web.cs.unibo.it\/richieste"}]
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 4 in /in/9falD on line 42 Notice: Undefined variable: data in /in/9falD on line 43 [{"0":"http:\/\/ltw1319.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1330.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1336.web.cs.unibo.it\/richieste"},{"0":"http:\/\/ltw1311.web.cs.unibo.it\/richieste"}]
Output for 5.2.0 - 5.2.17
Notice: Undefined offset: 4 in /in/9falD on line 42 Notice: Undefined variable: data in /in/9falD on line 43 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/9falD on line 43
Output for 5.0.0 - 5.1.6
Notice: Undefined offset: 4 in /in/9falD on line 42 Fatal error: Call to undefined function json_encode() in /in/9falD on line 43
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/9falD 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/9falD on line 3