deimos krijgsman deimos krijgsman - 1 year ago 108
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(''.$gg.'');
$data = json_decode($json,true);
$stream = $data['link'];


its kinda working!

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

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

Answer Source

this is called concatenation and your mostly right:

$json = file_get_contents(''.$gg);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download