2016-10-02 9 views
-2

こんにちは私は変数に変数を使用しようとしています(私はそれを説明する方法を知らない:P)とにかく私は基本的に私は$ gg(youtube video id)がほしいと思ったすべてを試しました リンクに追加 そのちょっと作業:変数内の変数?

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私を助けてください!

が、私はこれは、連結と呼ばれ、あなたのほとんどは右され

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

「いくつかのことは間違っている」とはどういう意味ですか? – nogad

答えて

0

$ GGを作成するときに、まだいくつかのものが間違っている:

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

回答が投稿された回答と異なる理由と、なぜOP問題を解決するのか説明してください。 – Franco

+0

変なことに動作していません –

+0

@deimoskrijgsmanがテストし、変数をハードコードして動作するかどうかを確認します – nogad

0

私はあなたの質問が正しい取得する場合は、あなたがしようとしているものこれは次のとおりです:$variable = "Hello ".$another_variable;

これはPHPの初めに学ぶ最も基本的なものの1つです。

$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!