3v4l.org

run code in 300+ PHP versions simultaneously
<?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,category); }); //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 git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant "category" in /in/LsLHK:15 Stack trace: #0 [internal function]: {closure}(Object(SimpleXMLElement), Object(SimpleXMLElement)) #1 /in/LsLHK(14): usort(Array, Object(Closure)) #2 {main} thrown in /in/LsLHK on line 15
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.1 ms | 401 KiB | 8 Q