I have a query which returns an array of values. My task is to convert this results as comma separated values like:
value1,value2....valuen
I tried using explode and implode.. But it didnt worked. May be am not using it in the proper way..Here's my code:
Query
$this->db->select("product_name")
->from('sale_items')
->where('sale_items.sale_id',4221);
$q1 = $this->db->get();
if ($q1->num_rows() > 0) {
foreach (($q1->result()) as $row1) {
$prdtarray[] = explode(",", $row1->product_name);
$data1[] = $row1;
}
echo print_r($prdtarray);
$product=implode(',',$prdtarray);
echo $product ;
The result is:
$prdtarray
Array ( [0] => Array ( [0] => Insole Premium Shore 30 ) [1] => Array ( [0] => G Diabetic Premium closed Sandal Black size 09 ) ) 1
$product
Array,Array
My expected result is :
( Insole Premium Shore 30 ,G Diabetic Premium closed Sandal Black size 09 )
How can I achieve this?? Can anyone help me out..
$prdtarray[] = $row1->product_name;