How to remove Duplicate Array element by specifying index like article_id That means there would no other element having same article id in array .
This is what i am getting
$data["related_post"] =$CI->Article_model->get_related_post($SearchTag);
and
echo "<pre>";
print_r($data["related_post"]);
echo "</pre>";
Output:
Array
(
[0] => stdClass Object
(
[article_id] => 49
[article_viewed] => 156
[article_title] => Copy 1 column to another by mysql query
[article_url] => copy-1-column-to-another-by-mysql-query
[article_status] => active
[tag_name] => mysql
)
[1] => stdClass Object
(
[article_id] => 49
[article_viewed] => 156
[article_title] => Copy 1 column to another by mysql query
[article_url] => copy-1-column-to-another-by-mysql-query
[article_status] => active
[tag_name] => sql
)
[2] => stdClass Object
(
[article_id] => 49
[article_viewed] => 156
[article_title] => Copy 1 column to another by mysql query
[article_url] => copy-1-column-to-another-by-mysql-query
[article_status] => active
[tag_name] => unique-key
)
)
array_unique()(maybe buggy on instances) or an simpleforeachand create an new array where the index is the id.SELECT DISTINCT(article_id)...in your query$this->group_by('article_id')or$this->db->distinct();or$this->db->select('DISTINCT(article_id)');