警告:explode()期望参数2为字符串,给定[闭合]数组

警告:explode()期望参数2为字符串,给定[闭合]数组

问题描述:

The Script:

<?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);

?>

I have the following entry in one row of the column "some_text_id":

164, 165, 166

I am looking to "explode" this by the comma and have it stored in an array, so I can select the numbers individually, e.g.:

myarray[0], myarray[1], myarray[2]

Though I am getting the following error message:

Warning: explode() expects parameter 2 to be string, array given in ... (points to the explode function)

Any suggestions on how to do this?

脚本: p>

 &lt;?php 
 \  n $ tqs =“SELECT * FROM`table_two`”; 
 $ tqr = mysqli_query($ dbc,$ tqs); 
 $ row = mysqli_fetch_assoc($ tqr); 
 $ thearray [] = $ row ['some_text_id  ']; 
 
 //打印例如:数组([0] =&gt; 164,165,166)
 print_r($ thearray); 
 
 echo“&lt; br /&gt;&lt; br /  &gt;“; 
 echo”&lt; br /&gt;&lt; br /&gt;“; 
 
 $ thearray = explode(”,“,$ thearray); 
 print_r($ thearray); 
 \  n?&gt; 
  code>  pre> 
 
 

我在“some_text_id” em>列的一行中有以下条目: p> \ n

  164,165,166 
  code>  pre> 
 
 

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

  myarray [0],myarray [1],myarray [2] 
  code>  pre> 
 
  

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

警告:explode()期望参数2为字符串,数组以...给出(指向 EXPLO de function) p> blockquote>

有关如何执行此操作的任何建议吗? p> div>

Skip the part where you put the database results into an array. It's completely unnecessary:

<?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);

?>