Php 比较一个数组和输出的值

Php 比较一个数组和输出的值,php,arrays,magento,Php,Arrays,Magento,我有一个数组可以多次包含相同的值。我试图找到一种方法来比较数组中的值,并且只输出每个值一次 $_just_a_tier = array(); foreach ($_associatedProducts as $_item){ // count all products $_tierprice = $this->getTierPrices($_item); foreach ($_tierprice as $_ay){

我有一个数组可以多次包含相同的值。我试图找到一种方法来比较数组中的值,并且只输出每个值一次

$_just_a_tier = array();

foreach ($_associatedProducts as $_item){
// count all products

    $_tierprice = $this->getTierPrices($_item);
     foreach ($_tierprice as $_ay){                              
                $_tier = $_ay['price_qty'];                              
               // echo $_tier.' | ';

                $_just_a_tier[] = $_tier;
      }
}

print_r($_just_a_tier);
这将输出,例如:

Array
(
    [0] => 36
    [1] => 50
    [2] => 72
    [3] => 108
    [4] => 110
    [5] => 120
    [6] => 144
    [7] => 180
    [8] => 360
    [9] => 540
    [10] => 960
    [11] => 20
    [12] => 30
    [13] => 36
    [14] => 72
    [15] => 108
    [16] => 144
    [17] => 180
    [18] => 360
    [19] => 540
)

谢谢。

PHP中有一个名为的内置函数可以为您解决这个问题。

您看过PHP的函数了吗