警告:explode()期望参数2是字符串,给定数组

ftx*_*txn 1 php arrays explode

剧本:

<?php

    $tqs = "SELECT * FROM `table_two`";
    $tqr = mysqli_query($dbc, $tqs);
    $row = mysqli_fetch_assoc($tqr);
    $thearray[] = $row['some_text_id'];

    // Prints e.g.: Array ( [0] => 164, 165, 166 )
    print_r($thearray);

    echo "<br/><br/>";
    echo "<br/><br/>";

    $thearray = explode(", ", $thearray);
    print_r($thearray);

?>
Run Code Online (Sandbox Code Playgroud)

我在"some_text_id"列的一行中有以下条目:

164, 165, 166
Run Code Online (Sandbox Code Playgroud)

我希望用逗号"爆炸"这个并将它存储在一个数组中,所以我可以单独选择数字,例如:

myarray[0], myarray[1], myarray[2]
Run Code Online (Sandbox Code Playgroud)

虽然我收到以下错误消息:

警告:explode()期望参数2是字符串,在...中给出的数组(指向爆炸函数)

有关如何做到这一点的任何建议?

Joh*_*nde 6

跳过将数据库结果放入数组的部分.这是完全没必要的:

<?php

    $tqs = "SELECT * FROM `table_two`";
    $tqr = mysqli_query($dbc, $tqs);
    $row = mysqli_fetch_assoc($tqr);

    // Prints e.g.: 164, 165, 166
    print_r($row['some_text_id']);

    echo "<br/><br/>";
    echo "<br/><br/>";

    $thearray = explode(", ", $row['some_text_id']);
    print_r($thearray);

?>
Run Code Online (Sandbox Code Playgroud)