3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } echo $ulrscomprati[$count]; $result_from_server = json_encode($ulrscomprati,$data); echo $result_from_server;
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key 4 in /in/rm9Q4 on line 42 Warning: Undefined variable $data in /in/rm9Q4 on line 43 Deprecated: json_encode(): Passing null to parameter #2 ($flags) of type int is deprecated in /in/rm9Q4 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 8.0.0 - 8.0.30
Warning: Undefined array key 4 in /in/rm9Q4 on line 42 Warning: Undefined variable $data in /in/rm9Q4 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.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined offset: 4 in /in/rm9Q4 on line 42 Notice: Undefined variable: data in /in/rm9Q4 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 7.3.32 - 7.3.33
[{"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/rm9Q4 on line 42 Notice: Undefined variable: data in /in/rm9Q4 on line 43 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/rm9Q4 on line 43
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Notice: Undefined offset: 4 in /in/rm9Q4 on line 42 Fatal error: Call to undefined function json_encode() in /in/rm9Q4 on line 43
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/rm9Q4 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/rm9Q4 on line 3

preferences:
274.44 ms | 401 KiB | 359 Q