my code :
$read = $this->m_crud->read_data("subscribe","*");
$newData=array();
foreach($read as $key){
$newData[] = $key["email"];
}
$to = implode(",",$newData);
echo json_encode($to)
result :
"test1@gmail.com, test2@gmail.com"
question : how to make the results look like this:
"test1@gmail.com", "test2@gmail.com"
Just remove the implode() Function.The implode() is a builtin function in PHP and is used to join the elements of an array. The separator (,) parameter of implode() is recommended to always use two parameters for backwards compatibility.
<?php
$read = $this->m_crud->read_data("subscribe","*");
$newData=array();
foreach($read as $key){
$newData[] = $key["email"];
}
echo json_encode($newData);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.