I am using codeigniter geting comma separated values but not working fine. i am sharing all code like first output foreach after gating result not show comma separated values than second show array print value aftra need output comma separated values like SLR,ACCN
Model code here
public function display_coach_name($coachID='')
{
$db2 = $this->load->database('rail',TRUE);
$ids = explode(',',$coachID);
$db2->select('coach_name');
$db2->from('mcc_coach');
$db2->where_in('id',$ids);
$query = $db2->get();
//echo $db2->last_query(); die;
if ($query->num_rows() > 0):
return $query->result_array();
else:
return 0;
endif;
}
output
<?php foreach ($coachname as $val){ echo $pizza = $val['coach_name']; }?>
//---------------------foreach-----------------output---
SLRACCN
array print
$coachname = $this->rail_ceil_model->display_coach_name($coachID);
echo"<pre>";
print_r($coachname);
//---------------------output----------------------
Array
(
[0] => Array
(
[coach_name] => GS
)
[1] => Array
(
[coach_name] => SLR
)
)
Array
(
[0] => Array
(
[coach_name] => GS
)
[1] => Array
(
[coach_name] => SLR
)
)
Array
(
[0] => Array
(
[coach_name] => GS
)
[1] => Array
(
[coach_name] => SLR
)
)
Array
(
[0] => Array
(
[coach_name] => GS
)
[1] => Array
(
[coach_name] => SLR
)
)
I have need output
SLR,ACCN