3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <products><product><product_code>0084064919005</product_code><name>Spy Men's Hielo Sunglasses</name><stock>1</stock><regular_price>94.95</regular_price><sale_price>44.93</sale_price><brand>Spy Optic Inc </brand><gender/><category>Sunglasses</category><product_description>The Spy Men's Hielo Sunglasses are a classic hit maker. The frames are custom built out of high quality propionate, a lightweight durable material. An 8 base curve ARC lens gives you perfect clarity without distortion and gives you 100% UV protection.</product_description><buy_url>http://www.sunandski.com/ProductDetails.asp?ProductCode=0084064919005</buy_url><large_image_url>imgs/products/lrg/0084064919005.jpg</large_image_url><remote_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919005-2T.jpg</remote_image_url><small_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919005-1.jpg</small_image_url><size/><savings>53</savings></product><product><product_code>0084064919010</product_code><name>Spy Men's Hsx Sunglasses</name><stock>10</stock><regular_price>104.95</regular_price><sale_price>49.93</sale_price><brand>Spy Optic Inc </brand><gender/><category>Sunglasses</category><product_description>The Spy Men's Hsx Sunglasses is packed with all the features and style you expect from the Spy line of sunglasses. The frames are made out of ultra-lightweight and durable Grilamid. An 8x4-base toric arc lenses give you vision without distortion. These glasses are scratch and impact resistant so that they will be your favorite for a long time to come.</product_description><buy_url>http://www.sunandski.com/ProductDetails.asp?ProductCode=0084064919010</buy_url><large_image_url>imgs/products/lrg/0084064919010.jpg</large_image_url><remote_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919010-2T.jpg</remote_image_url><small_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919010-1.jpg</small_image_url><size/><savings>53</savings></product><product><product_code>0084064919011</product_code><name>Spy Men's Hsx Sunglasses</name><stock>6</stock><regular_price>149.95</regular_price><sale_price>69.93</sale_price><brand>Spy Optic Inc </brand><gender/><category>Sunglasses</category><product_description>The Spy Men's Hsx Sunglasses are made from lightweight durable Grilamid. It has 8x4 base Toric Arc Lenses give you superior vision without distortion. It offers 100% UV Protection to spare your eyes from the sun s harmful rays. Metal detailing give these glasses extra style.</product_description><buy_url>http://www.sunandski.com/ProductDetails.asp?ProductCode=0084064919011</buy_url><large_image_url>imgs/products/lrg/0084064919011.jpg</large_image_url><remote_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919011-2T.jpg</remote_image_url><small_image_url>http://www.sunandski.com/v/vspfiles/photos/0084064919011-1.jpg</small_image_url><size/><savings>54</savings></product> </products> XML ); $arr=array(); foreach($xml->product as $aTask) { $arr[]=$aTask; } //print_r($arr); usort($arr,function($a,$b){ return usort($a,"cmp_obj"); }); //print_r($arr); $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <products> </products> XML ); foreach($arr as $aTask) { $tTask=$xml->addChild($aTask->getName()); $tTask->addChild($aTask->date->getName(),(string)$aTask->name); $tTask->addChild($aTask->title->getName(),(string)$aTask->category); $tTask->addChild($aTask->description->getName(),(string)$aTask->product_description); } echo $xml->asXML();
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: usort() expects parameter 1 to be array, object given in /in/IOEkh on line 15 Warning: usort() expects parameter 1 to be array, object given in /in/IOEkh on line 15 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 27 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 28 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 29 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 27 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 28 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 29 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 27 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 28 Warning: SimpleXMLElement::addChild(): Element name is required in /in/IOEkh on line 29 <?xml version="1.0"?> <products> <product/><product/><product/></products>
Output for hhvm-3.12.0
Warning: Invalid operand type was used: usort expects array(s) or collection(s) in /in/IOEkh on line 15 Warning: Invalid operand type was used: usort expects array(s) or collection(s) in /in/IOEkh on line 15 Warning: Element name is required in /in/IOEkh on line 27 Warning: Element name is required in /in/IOEkh on line 28 Warning: Element name is required in /in/IOEkh on line 29 Warning: Element name is required in /in/IOEkh on line 27 Warning: Element name is required in /in/IOEkh on line 28 Warning: Element name is required in /in/IOEkh on line 29 Warning: Element name is required in /in/IOEkh on line 27 Warning: Element name is required in /in/IOEkh on line 28 Warning: Element name is required in /in/IOEkh on line 29 <?xml version="1.0"?> <products> <product/><product/><product/></products>
Output for hhvm-3.10.0
Warning: Invalid operand type was used: usort expects array(s) or collection(s) in /in/IOEkh on line 19 Warning: Invalid operand type was used: usort expects array(s) or collection(s) in /in/IOEkh on line 19 Warning: Element name is required in /in/IOEkh on line 35 Warning: Element name is required in /in/IOEkh on line 37 Warning: Element name is required in /in/IOEkh on line 18 Warning: Element name is required in /in/IOEkh on line 35 Warning: Element name is required in /in/IOEkh on line 37 Warning: Element name is required in /in/IOEkh on line 18 Warning: Element name is required in /in/IOEkh on line 35 Warning: Element name is required in /in/IOEkh on line 37 Warning: Element name is required in /in/IOEkh on line 18 <?xml version="1.0"?> <products> <product/><product/><product/></products>
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/IOEkh on line 14
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected T_FUNCTION in /in/IOEkh on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/IOEkh on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/IOEkh on line 14
Process exited with code 255.