I am using this code which calls the period_id :
$cart = $this->GetUserCart();
$dataset = array();
while ($data = $cart->fetch_array()) {
$dataset[] = $data['period_id'];
}
so I need to implode the result so they can be separated by comma
$p = implode(",",$dataset);
So in the usercart function will call for example, 3 distinct period_id
so I need to finish like this :
$p='2,5,3';
Your code is correct. Maybe you just have to echo it.
$dataset = array();
while ($data = $cart->fetch_array()) {
$dataset[] = $data['period_id'];
}
$p = implode(',', $dataset);
echo $p; //you just need to echo it
I think if
$p = implode(",",$dataset);
if $dataset = array("1", "5", "3");
when you echo $p ; //output will be 1,5,3
echo $p ; //output will be 1,5,3
put if you add this :
$p = "'".implode(",",$dataset)."'";
echo $p ; //output will be '1,5,3'
and that is what you need if i understand you so
$p = '1,5,3';
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.