3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if( !function_exists('simplexml_load_string') || !function_exists('json_encode') ) die('Not supported yet'); $data = array( <<<XML <Hotels> <Hotel> <Mapper><ProviderSupplierName/></Mapper> </Hotel> </Hotels> XML , <<<XML <Hotels> <Hotel> <Mapper> <ProviderSupplierName/> </Mapper> </Hotel> </Hotels> XML ); foreach($data as $resultXML){ echo $resultXML . PHP_EOL; $sxml = simplexml_load_string($resultXML); echo json_encode($sxml); echo PHP_EOL; }
Output for 5.2.0 - 5.3.29, 5.5.27 - 5.5.38, 5.6.11 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
<Hotels> <Hotel> <Mapper><ProviderSupplierName/></Mapper> </Hotel> </Hotels> {"Hotel":{"Mapper":{"ProviderSupplierName":{}}}} <Hotels> <Hotel> <Mapper> <ProviderSupplierName/> </Mapper> </Hotel> </Hotels> {"Hotel":{"Mapper":{"ProviderSupplierName":{}}}}
Output for 5.4.0 - 5.5.26, 5.6.0 - 5.6.10, hhvm-3.10.0
<Hotels> <Hotel> <Mapper><ProviderSupplierName/></Mapper> </Hotel> </Hotels> {"Hotel":{"Mapper":{"0":{}}}} <Hotels> <Hotel> <Mapper> <ProviderSupplierName/> </Mapper> </Hotel> </Hotels> {"Hotel":{"Mapper":{"ProviderSupplierName":{}}}}
Output for 4.3.0 - 5.1.6
Not supported yet