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'];
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);
If I get your question correct, what you are trying to do is this: $variable = "Hello ".$another_variable;
This is one of the most basic things you learn at the beginning of php.
$w = "World!";
$h = "Hello ".$w;
echo $h;
/*
* This will result printing out "Hello World";
* The reason for this is because $w is a "Container",
* that means the variable is keeping some information in it, basicly: it exists.
* Now you can also use this in functions:
*/
function some_function($full_string){
return $full_string;
}
echo some_function($h." What a good day!"); Which will result in "Hello World! What a good day!"
// I hope this was what you was looking for!