如何获得子阵列的唯一值?

时间:2016-11-30 07:28:13

标签: php arrays string array-unique

实际上,我正在获得阵列和子阵列。我想从子阵列中获取唯一值。我尝试了很多东西,但它对我不起作用。这是我的数组值

  Array
(
    [title] => Array
        (
            [0] => Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.400 - Rs.800),Multicuisine Restaurants,Pure Veg Restaurants,Restaurants,Cake Shops,Food,Inexpensive Restaurents,Moderate Restaurants (Rs.,,
            [1] => Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterers,Bakery,Cake Shops,Caterer,,Bakery,Cake Shops,Caterers
            [2] => Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Delivery Restaurants,Home Deliv,,Home Delivery Restaurants
            [3] => ,,,Chocolate Manufacturers,,Chocolate Manufacturers,,Chocolate Manufacturers,,Chocolate Manufacturers,,Chocolate Manufacturers
            [4] => ,,,Chocolate Manufacturers,,Chocolate Manufacturers,,Chocolate Manufacturers
            [5] => 
        )

)

我想要的只是从中获取唯一数据并删除空白值

我尝试过像

for($i=0;$i<count($listing);$i++){
        $tags['title'][$i] = $listing[$i]->cat_title;
        $tags['taa'] = array_unique($tags['title'][$i]);
    }
    echo '<pre>';
    print_r($tags);
    echo '</pre>';

$listing我从db获取数据。

0 个答案:

没有答案