Here I'am using php array concept,I have a array in php just like $array=array('name1,name2');I want to convert this array into following format for some requirement $array=('name1','name2');
And please let me know,how to convert first array into second array format and also what is the difference between this two array format. Please help me...
This is what I have done so far
foreach($query->result_array() as $row) {
$galleries[]= $row["subjects"];
$ids = join("','",$galleries);
}
echo $pps="SELECT * FROM student_register
WHERE s_name IN ('$ids')";
I got output like this :
SELECT * FROM student_register
WHERE s_name IN ('english,malayalam,hindi')
Instead of above I want following output
SELECT * FROM student_register
WHERE s_name IN ('english','malayalam','hindi')
Hope this will help you :
Use CI query builder's where_in
to get the desired result
foreach($query->result_array() as $row)
{
$ids[] = $row["subjects"];
}
$this->db->where_in('s_name', $ids);
$result = $this->db->get('student_register')->result();
//print_r($result);
echo $this->db->last_query();
For more : https://www.codeigniter.com/user_guide/database/query_builder.html