如何只从数据库中获取值



当我打印时,我会得到类似的结果

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'];

您可以简单地循环遍历数组,并将每个值添加到一个变量中。数组或字符串:

<?php
$dataset = $this->Admin_model->getSubscribers();
$outputArray = [];
foreach($dataset as $row) {
$outputArray[] = $row['subscription_email'];
}
// in case you wish for an array
$to_email = $outputArray;
// in case you need a comma separated string:
$to_email = implode(',', $outputArray); 
?>

相关内容

  • 没有找到相关文章