我如何在<code>Date</code>对象上回显数组中的内容(例如<a href="arraydata">)

时间:2019-04-10 15:27:45

标签: php

I'm trying to make it where I can go to a link of off a YouTube API. (MP4), but I can't figure out how to make the link to the MP4 clickable (such as <a href=data>). I am wanting to do this for a Android project, basically just a completely online Android converter since FLVTO and onlinevideoconverter is super annoying, pops up viruses, or pops up "Your Galaxy S7 Edge is infected! install app to fix!". Here's what I've tried.

$formats = $array["streamingData"]["formats"];
    for ($a = 0; $a <= (count($formats) - 1); $a++){
        $data[] = array(
            "url" => $array["streamingData"]["formats"][$a]["url"]
            echo "<a href='"$array['streamingData']['formats'][$a]['url']"'>downloadlink</a>"

);

or

$formats = $array["streamingData"]["formats"];
    for ($a = 0; $a <= (count($formats) - 1); $a++){
        $data[] = array(
            $url => $array["streamingData"]["formats"][$a]["url"]
        );
        echo "<a href='"$url"'>adsf</a>";

3 个答案:

答案 0 :(得分:3)

您需要连接字符串

 echo "<a href='" . $url . "'>adsf</a>";

答案 1 :(得分:2)

如果要显示,为什么还放在数组中?随便吧。

 $formats = $array["streamingData"]["formats"];
for ($a = 0; $a <= (count($formats) - 1); $a++){
   echo "<a href='".$formats[$a]['url']."'>downloadlink</a>"; 
}

答案 2 :(得分:2)

正如eric MC所说,您可以像这样将字符串连接起来:

echo "<a href='" . $url . "'>adsf</a>";

或使用printf(更易于阅读的imo)

printf("<a href='%s'>adsf</a>", $url);