php - How to trim array to show only non duplicated values? -


i'm struggling array results:

$result = db::getinstance()->executes( $sql );       $this->smarty->assign( array(          'result' => $result     )); 

this array:

array (  [0] => array ( [id_tag] => 2 [id_post] => 5 [id_smart_blog_post_shop] => 5 [id_smart_blog_post] => 5 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [1] => array ( [id_tag] => 2 [id_post] => 6 [id_smart_blog_post_shop] => 6 [id_smart_blog_post] => 6 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [2] => array ( [id_tag] => 2 [id_post] => 7 [id_smart_blog_post_shop] => 7 [id_smart_blog_post] => 7 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [3] => array ( [id_tag] => 2 [id_post] => 8 [id_smart_blog_post_shop] => 8 [id_smart_blog_post] => 8 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [4] => array ( [id_tag] => 2 [id_post] => 9 [id_smart_blog_post_shop] => 9 [id_smart_blog_post] => 9 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [5] => array ( [id_tag] => 4 [id_post] => 10 [id_smart_blog_post_shop] => 10 [id_smart_blog_post] => 10 [id_shop] => 1 [id_lang] => 1 [name] => xppower )  [6] => array ( [id_tag] => 2 [id_post] => 11 [id_smart_blog_post_shop] => 11 [id_smart_blog_post] => 11 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [7] => array ( [id_tag] => 2 [id_post] => 12 [id_smart_blog_post_shop] => 12 [id_smart_blog_post] => 12 [id_shop] => 1 [id_lang] => 1 [name] => microchip )  [8] => array ( [id_tag] => 4 [id_post] => 13 [id_smart_blog_post_shop] => 13 [id_smart_blog_post] => 13 [id_shop] => 1 [id_lang] => 1 [name] => xppower )  )  

and, want show name values once like:

microchip, xppower 

and not this:

microchip, microchip, microchip, microchip, microchip, xppower, microchip, microchip, xppower 

i'm trying use array_unique show non duplicate values, works partially , shows only.

microchip value once , leaves xppower:

$tags = db::getinstance()->executes( $sql );  $result = array_values(array_unique($tags));  $this->smarty->assign( array(      'result' => $result )); 

array printed:

array (   [0] => array ( [id_tag] => 2 [id_post] => 5 [id_smart_blog_post_shop] => 5 [id_smart_blog_post] => 5 [id_shop] => 1 [id_lang] => 1 [name] => microchip )   )  

this $sql function if want know

$sql = 'select * '._db_prefix_.'smart_blog_post_tag p inner join              '._db_prefix_.'smart_blog_post_shop s on p.id_post=s.id_smart_blog_post , s.id_shop = '.(int) context::getcontext()->shop->id.' inner join              '._db_prefix_.'smart_blog_tag t on p.id_tag= t.id_tag t.id_lang = '.(int)$id_lang.' limit '.$limit; 

$names = array(); foreach ($tags $tag) {     $names[$tag['name']] = 1; } print_r(array_keys($names)); 

Comments