I’m pretty new to programming and PHP. This is the first language that I am attempting to learn (aside from HTML and CSS).
Part of this script was taken off the net, part of it I wrote. It is used to pull some information from a youtube feed and then input that data dynamically into a jQuery rotator.
I’m just looking for some constructive criticism if anyone is bored. Just want to get better at this.
<?php
function some_video_rotator() {
//these are the settings for your youtube feed and display
$settings = array(
'user' => 'ayoutubeuser', //YouTube user
'limit' => 5, //number of videos to pull
'width' => 300, //width of video in pixels
'height' => 200 //height of video in pixels
);
//this is the youtube api feed data location, stored as an array in '$data'
$data = @json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/users/'.$settings['user'].'/uploads?alt=json'), TRUE);
// some definitions...
$counter = 0;
$a = 0;
$url_store = array();
$title_store = array();
$ycontent_store = array();
foreach($data['feed']['entry'] as $vid)
{
// as $a increments it asigns each video url to the $url_store array...
// this functions for the title and video as well
$a++;
$url = $vid['media$group']['media$content'][0]['url'];
$url_store[$a] = $url;
//assigns to $title_store array
$title = $vid['title']['$t'];
$title_store[$a] = $title;
// assigns to $ycontent_store array
$ycontent = $vid['content']['$t'];
$ycontent_store[$a] = $ycontent;
// counter was set at '0'. This says if counter is equal to the 'limit' (in settings
// to break the increase counting.
$counter++;
if($counter == $settings['limit'])
{
break;
}
}
?>
the $url_store, $title_store, and $ycontent stores are then used within HTML to pull the parts of the youtube feed I need. Most of the comments are for me (cause I won’t remember that stuff later).
Thoughts anyone? Thanks in advance.