3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getXML($url) { $Proxy = getenv("HTTP_PROXY"); if (strlen($Proxy) > 1) { $r_default_context = stream_context_get_default(array('http' => array('proxy' => $Proxy,'request_fulluri' => True,),)); libxml_set_streams_context($r_default_context); } $daten = simplexml_load_file($url); return ($daten); } ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); ini_set("max_execution_time", 0); ini_set("memory_limit", "10000M"); //These are here to hold back any errors from a user agent sniffer, if applicable. //I only put these here as a precaution and to add things to my code to make it look //like I was doing something important. echo "\t\t\t\t\t",'<div class="row center">',PHP_EOL; //For bootstrap, to wrap the videos up in a row so they can be displayed properly $user = 'KazenRacing'; //Set the username for later use $xml = getXML("http://gdata.youtube.com/feeds/api/users/$user/uploads"); //Loads the users Youtube feed data $total = $xml->totalResults; //This will give you how many videos are available in the feed for ($i=0; $i < $total; $i++){ //For loop determining how many videos to display based on the $total $id = basename($xml->entry[$i]->id); //This gets the id for each video. $title = $xml->entry[$i]->title; //This will get the title for each video. $recorded = date('jS F, Y', strtotime($xml->entry[$i]->recorded)); //This will get the recorded time of each video and display it by Day Month, Year. If not set will display 31st December, 1969 $description= $xml->entry[$i]->content; //This will get the video description, if any. echo "\t\t\t\t\t\t", '<div class="col-md-3 col-sm-6 col-xs-9 yt-div">',PHP_EOL, "\t\t\t\t\t\t\t", '<div class="well well-sm text-center">',PHP_EOL, "\t\t\t\t\t\t\t\t", '<h4>'.$title.'</h4>',PHP_EOL, "\t\t\t\t\t\t\t\t", '<div class="caption">',PHP_EOL, "\t\t\t\t\t\t\t\t\t", '<h5>'.$recorded.'</h5>',PHP_EOL, "\t\t\t\t\t\t\t\t\t",'<a rel="Video Gallery" class="swipebox" href="//youtu.be/'.$id.'" title="'.$title.'">', PHP_EOL, "\t\t\t\t\t\t\t\t\t\t",'<img src="thumbs.php?src=http://img.youtube.com/vi/'.$id.'/mqdefault.jpg&w=256" class="img-responsive img-thumb center-block" alt="'.$title.'"></a>',PHP_EOL, "\t\t\t\t\t\t\t\t\t",'<h6 class="text-justify">'.$description.'</h6>',PHP_EOL, "\t\t\t\t\t\t\t\t",'<hr>',PHP_EOL,//"\t\t\t\t\t\t\t\t\t",'<a href="//youtu.be/'.$id.'" class="btn btn-info btn-outlined" role="button">View on Youtube</a>',PHP_EOL, "\t\t\t\t\t\t\t\t", '</div>',PHP_EOL, "\t\t\t\t\t\t", '</div>', PHP_EOL, "\t\t\t\t\t", '</div>',PHP_EOL; //This echo displays all the information we set before using the $id, $title, $recorded, and $description variables. if ($i % 4 == 3) { echo "\t\t\t\t\t",'</div>',PHP_EOL, "\t\t\t\t\t",'<div class="row">',PHP_EOL; } //This if statement makes sure there is a new row for every four videos. } echo "\t\t\t\t\t",'</div>',PHP_EOL; //And here is the closing tag for our row div. ?>

preferences:
42.01 ms | 402 KiB | 5 Q