deimos krijgsman deimos krijgsman - 2 months ago 17
JSON Question

Variable in a Variable?

Hi guys i am trying to use a variable in a variable (i don't know how to explain it :P) anyways i've tried everything so basically i want $gg (youtube video id)
added to to a link please help me out

foreach ($searchResponse['items'] as $searchResult) {
switch ($searchResult['id']['kind']) {
case 'youtube#video':
$videos .= sprintf('<dl>%s %s</dl>', $searchResult [''],
$searchResult['videoId']."<iframe style='width:100%;height:99px;border:0;overflow:hidden' scrolling='no' align='middle' src=".$stream."&color=00e464> scrolling='no'></iframe>");
$gg = $searchResult->id->videoId;
$json = file_get_contents('http://www.youtubeinmp3.com/fetch/?format=JSON&video=http://www.youtube.com/watch?v='.$gg.'');
$data = json_decode($json,true);
$stream = $data['link'];
break;

}
}


EDIT:
its kinda working!

but still some things are going wrong when i create $gg

$gg = $searchResult['id']['videoId'];

Answer

this is called concatenation and your mostly right:

$json = file_get_contents('http://www.youtubeinmp3.com/fetch/?format=JSON&video=http://www.youtube.com/watch?v='.$gg);
Comments