How will I merge the two array under name into one array and make it unique. As you can see the result on the [0] is
Beef Adobo
qwerty
iswi
and on 1 is
qwerty
iswi
I want the both of them to be in one array and the result should be
Beef Adobo
qwerty
iswi
query:
public function get_halal($name) {
$terms = explode(',', $name);
foreach ($terms as $name) {
$this->db->distinct();
$this->db->select('r_name');
$this->db->from('recipe');
$this->db->join('menu', 'menu.recipe_id = recipe.recipe_id');
$this->db->join('ingredient', 'ingredient.ingredient_id = menu.ingredient_id');
$this->db->where('menu.category_id = 2');
$this->db->like('ingredient.name', $name);
$query = $this->db->get()->result();
$data[] = $query;
}
return $data;
}
controller:
public function ajaxSearchHalal() {
postdata = file_get_contents("php://input");
if (isset($postdata)) {
$post = json_decode($postdata);
$name = $post->name;
if ($this->user_model->get_halal($name)) {
$user_id = $this->user_model->get_halal($name);
$data = array(
'name' => $user_id,
);
echo json_encode($data);
} else {
echo json_encode("false");
}
} else {
echo "Error!";
}
}




menutable exactly?menutable in the database?menutable is because you shouldn't have to worry about merging your result arrays. You just need to fix your query. Provide your tables with examples so that we can give you the best answer.