如何只获取数据库中的值?

当我打印时,我得到的结果如下

Array ( [0] => Array ( [subscription_email] => example@gmail.com ) [1] => Array ( [subscription_email] => test@gmail.com ) )

但我想得到它

example@gmail.com, test@gmail.com

这是我的结果代码

$data['subscribers'] = $this->Admin_model->getSubscribers();
$to_email = $data['subscribers'];


慕尼黑8549860
浏览 87回答 1
1回答

蝴蝶刀刀

您可以简单地循环遍历数组并将每个值添加到变量中。数组或字符串:<?php&nbsp; &nbsp; $dataset = $this->Admin_model->getSubscribers();&nbsp; &nbsp; $outputArray = [];&nbsp; &nbsp; foreach($dataset as $row) {&nbsp; &nbsp; &nbsp; &nbsp;$outputArray[] = $row['subscription_email'];&nbsp; &nbsp; }&nbsp; &nbsp; // in case you wish for an array&nbsp; &nbsp; $to_email = $outputArray;&nbsp; &nbsp; // in case you need a comma separated string:&nbsp; &nbsp; $to_email = implode(',', $outputArray);&nbsp;?>
打开App,查看更多内容
随时随地看视频慕课网APP