Array unique for multi-dimensional arrays

@param array $array
@return array
770556
public static function arrayUnique(array $array)
    {
        // Serialize each array's value
        foreach ($array as &$value) {
            $value = serialize($value);
        }

        // Now remove duplicate strings
        $array = array_unique($array);

        // Now restore to its previous state with removed strings
        foreach ($array as &$value) {
            $value = unserialize($value);
        }

        return $array;
    }
272631
function getKeysForDuplicates(array $array)
    {
        $duplicates = $newArray = [];

        foreach ($array as $key => $value) {

            if ( ! isset($newArray[ $value ])) {
                $newArray[ $value ] = $key;
                continue;
            }

            if (isset($duplicates[ $value ])) {
                $duplicates[ $value ][] = $key;
            } else {
                $duplicates[ $value ] = [
                    $newArray[ $value ],
                    $key
                ];
            }
        }

        return $duplicates;
    }
325657
public static String[] unique(String[] arrays) {
        List<String> list = new ArrayList<>(arrays.length);
        for (String arr : arrays) {
            if (!list.contains(arr)) {
                list.add(arr);
            }
        }
        String[] res = new String[list.size()];
        int i = 0;
        for (String arr : list) {
            res[i++] = arr;
        }
        return res;
    }
342537
function uniqueArray(arr) {
  var result = [];

  for (var i = 0; i < arr.length; i++) {
    if (result.indexOf(arr[i]) === -1) {
      result.push(arr[i]);
    }
  }

  return result;
}
1116362
private function recursiveWalk($array) {
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $array[$k] = self::recursiveWalk($v);
        } else {
            $array[$k] = self::compareReplaceFaker($v);
        }
    }
    return $array;
  }
739435
public static function formatResponseArray(array $array): array
    {
        $formattedArray = [];

        foreach ($array as $item) {
            reset($item);
            $formattedArray[key($item)] = current($item);
        }

        return $formattedArray;
    }
269632
private function arrayFlatten(array $array)
    {
        $flat = array();
        foreach ($array as $arg) {
            switch (gettype($arg)) {
                case 'array':
                    $flat = array_merge($flat, $arg);
                    break;

                default:
                    $flat[] = $arg;
                    break;
            }
        }

        return $flat;
    }
328788
public static function array_diverse($array)
    {
        $result = array();

        foreach ($array as $key1 => $value1) {
            if (is_array($value1)) {
                foreach ($value1 as $key2 => $value2) {
                    $result[$key2][$key1] = $value2;
                }
            } else {
                $result[0][$key1] = $value1;
            }
        }

        return $result;
    }
162994
public static function flat(array $array)
    {
        $out = [];
        foreach ($array as $key=>$value) {
            if (is_array($value)) {
                //use recursion to get to the next array
                $out = array_merge($out, self::flat($value));
            } else {
                //add the value to the back of the array
                //if the value is not an array
                $out[] = $value;
            }
        }
        //return the resulting array
        return $out;
    }
471507
private function rksort(array $array)
    {
        ksort($array);
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                $array[$k] = $this->rksort($v);
            }
        }
        return $array;
    }
195324
public static function unique($array)
    {
        $unique = array();
        foreach ($array as $item) {
            if (!in_array($item, $unique, true)) {
                $unique[] = $item;
            }
        }

        return $unique;
    }
945027
protected function getArrayType(array $array) {
		$indices = count(array_filter(array_keys($array), 'is_string'));

		if ($indices == 0) {
			$type = self::ARRAY_TYPE_LIST;
		} elseif ($indices == count($array)) {
			$type = self::ARRAY_TYPE_DICT;
		} else {
			$type = self::ARRAY_TYPE_MIXED;
		}

		return $type;
	}
791678
public static function arrayUniqueMulti(array $aArray)
    {
        // Unique Array for return
        $aArrayRewrite = [];

        // Array with the md5 hashes
        $aArrayHashes = [];

        foreach ($aArray as $key => $item) {

            // Serialize the current element and create a md5 hash
            $hash = md5(serialize($item));

            /**
             * If the md5 didn't come up yet, add the element to to arrayRewrite,
             * otherwise drop it
             */

            if (!isset($aArrayHashes[$hash])) {

                // Save the current element hash
                $aArrayHashes[$hash] = $hash;

                // Add element to the unique Array
                $aArrayRewrite[$key] = $item;
            }
        }

        unset($aArrayHashes);
        unset($key);
        unset($item);
        unset($hash);

        return $aArrayRewrite;
    }
570472
private function filterUniqueRole($array)
    {
        $arrayRewrite = array();
        foreach ($array as $key => $parent)
        {
            foreach ($parent as $role)
            {
                if (!isset($arrayRewrite[$key]) || !in_array($role, $arrayRewrite[$key]))
                {
                    $arrayRewrite[$key][] = $role;
                }
            }
        }
        return $arrayRewrite;
    }
79161
public static function convertToOneDimensionalArray($array)
    {
        $newArray = array();
        if (is_array($array))
        {
            foreach ($array as $value)
            {
                $newArray = array_merge($newArray, self::convertToOneDimensionalArray($value));
            }
        } else
        {
            $newArray[] = $array;
        }

        return $newArray;
    }
246310
private function deserializeArrayRecursively(array $array): array
    {
        $data = [];
        foreach ($array as $key => $value) {
            $data[$key] = $this->deserializeValue($value);
        }

        return $data;
    }
1059742
public function toMappedArray(array $array)
    {
        $mappedArray = [];
        foreach ($this->getMapper() as $from => $to) {
            $mappedArray[$to] = $array[$from];
        }
        return $mappedArray;
    }