YouTube 配列をリクエストしようとしていますが、var ダンプで object(stdClass)#1 で始まるダンプが表示されます
<?php
$num = Rand(1,5);
switch ($num) {
case 1: header('Foo Fighters The Pretender'); $music= 'Foo Fighters The Pretender';
case 2: header('Arctic Monkeys Flourescent Adolescent'); $music= 'Arctic Monkeys Flourescent Adolescent';
case 3: header('The Strokes Under Cover of Darkness'); $music= 'under cover of darkness';
case 4: header('The White Stripes Seven Nation Army'); $music= 'the white stripes seven nation army';
case 5: header('Franz Ferdinand Michael'); $music= 'franz ferdinand michael';
}
$youtube_array = json_decode(file_get_contents("https://gdata.youtube.com/feeds/api/videos?alt=json&q=" . urlencode($music) , TRUE ));
var_dump($youtube_array);
echo "<h1>Your Song Is:</h1>";
echo $music;
echo "</p>";
echo "YouTube found this video about your Rock:";
echo "</p>";
$link = $youtube_array['feed']['entry'][0]['id']['$t'];
$link2 = substr($link, 42);
echo "<iframe width='960' height='720' src='http://www.youtube.com/embed/" . $link2 . "' frameborder='0' allowfullscreen></iframe>";
?>