3v4l.org

run code in 300+ PHP versions simultaneously
<?php function writeXML( $xml, $data ) { foreach( $data as $key => $value ) { if ( preg_match('/^(.*) (.*)=(.*)$/', $key, $matches) != false ) { $xml->startElement( $matches[1] ); $xml->writeAttribute( $matches[2], $matches[3]); if( is_array( $value )) { writeXML( $xml, $value ); $xml->endElement( ); continue; } $xml->text( $value ); $xml->endElement( ); } else { if( is_array( $value )) { $xml->startElement( $key ); writeXML( $xml, $value ); $xml->endElement( ); continue; } echo $key. "\n"; $xml->writeElement( $key, $value ); } } } $name = 'item'; $xml = new XmlWriter(); $xml->openMemory(); $xml->startDocument( '1.0', 'utf-8' ); $xml->startElement( $name ); $data = array( "episodeTitle" => 'test', "episodeDescription" => 'test', "pubDate" => 'test', "imdbid" => 'test', "MediaType" => "TV", "seasonNumber" => 1, "episodeNumber" => 1, "episodeImage" => array ( "url" => 'test', ), "duration" => 'test', "episodeKeywords" => "", "episodePopularity scale=" => 5, "VideoType" => "Episode", "country" => "United States", "language" => "en-us", "geoRestrictions" => 'test', //"dateAvailable" => $start_date, //"expDate" =>$end_date, "category" => 'test', "sourceID" => 'test', "streamType" => "SD", //TODO: multiple formats? "iOSAllowed" => 1, "subscription" => "yes", "price" => 0.00, "videoURL" => 'test', "showtitle" => 'test', "link" => "http://www.flixfling.com/movies/", "showdescription" => 'test', "showLogo" => array ( "url" => 'test', ), "showsourceID" => 'test', "showPubDate" => 'test', "showImdbid>" => 'test', "showCategory" => 'test', "showKeywords" => "", ); writeXML( $xml, $data);

preferences:
171.82 ms | 404 KiB | 5 Q