简体   繁体   English

如何在php中回显数组中的特定数据?

[英]How to echo a specific data from an array in php?

I want to take a specific from an array I have created. 我想从我创建的数组中获取特定内容。

Here's the code: 这是代码:

        try
    {
    // Conecting to MySQL
    $bdd = new PDO('mysql:host=localhost;dbname=horse', 'root', '');
    }
    catch(Exception $e)
    {
    // ERROR MESSAGE
    die('Erreur : '.$e->getMessage());
    }

    // Fetching the data from the table
    $reponse = $bdd->query('SELECT * FROM videos');

    $vidarray = array();

    while ($donnees = $reponse->fetch())
    {
    $videolink = $donnees['link'];

    $vidarray = array($videolink);

    print_r($vidarray);
    }
    echo $vidarray[1]);

    $reponse->closeCursor(); // Closing the request

I want to echo one of these specific data like this 我想回复这些特定数据之一

echo $array[1];

I want this to output "WubVcOaW-qs" with this. 我希望这个输出“WubVcOaW-qs”。

I am relativly new to php and I am sure this is pretty basic but can't find it anywhere. 我是相对较新的PHP,我相信这是非常基本但无法在任何地方找到它。

Thanks, 谢谢,

$array = array(
'S01tE08GSNg',
'WubVcOaW-qs',
'2n0ag4qmG5g',
'ni1UR-lXiZo',
'ynvz8P_aFwk'
);

echo $array[1];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM