[英]i have data “test1@gmail.com,test2@gmail.com” how to make the result look like this
我的代碼:
$read = $this->m_crud->read_data("subscribe","*");
$newData=array();
foreach($read as $key){
$newData[] = $key["email"];
}
$to = implode(",",$newData);
echo json_encode($to)
結果:
"test1@gmail.com, test2@gmail.com"
問題 :如何使結果看起來像這樣:
"test1@gmail.com", "test2@gmail.com"
只需刪除implode()函數。implode()是PHP中的內置函數,用於連接數組的元素。 建議將implode()的分隔符(,)參數始終使用兩個參數以實現向后兼容。
<?php
$read = $this->m_crud->read_data("subscribe","*");
$newData=array();
foreach($read as $key){
$newData[] = $key["email"];
}
echo json_encode($newData);
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.