duanmibei1929 2013-06-06 10:24
浏览 324

PHP转换数组以逗号分隔的字符串

I can't seemn to make this work could someone help identify what is incorrect:

$result = mysql_query("SELECT accounts_client_email.client_email FROM accounts_client_email WHERE accounts_client_email.accounts_client_id = 1", $con);

while( $row = mysql_fetch_assoc( $result)){
$new_array[] = $row; // Inside while loop
}

$tags = implode(', ', array($new_array));

echo $tags;
  • 写回答

5条回答 默认 最新

  • dongwang3066 2013-06-06 10:27
    关注

    You aren't adding correctly to the array, it should be:

    $new_array[] = $row['client_email'];
    

    And you are encapsulating the array into another array unnecessarily;

    use:

    $tags = implode(', ', $new_array);
    

    Or echo $tags; will just output "Array"

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程