Compares the collection against another collection or a plain PHP array based on its value. Returns a new Collection.
@param mixed[]|\CharlotteDunois\Collect\Collection  $arr
@return \CharlotteDunois\Collect\Collection
326312
function diff($arr) {
        if($arr instanceof self) {
            $arr = $arr->all();
        }
        
        return (new self(\array_diff($this->data, $arr)));
    }
451
public function unique() : Collection
    {
        $acc = [];
        foreach ($this->list as $item) {
            if (!in_array($item, $acc)) {
                $acc[] = $item;
            }
        }

        return self::from(...$acc);
    }
1325412
public function update(array $collection){
        foreach($collection as $key => $value){
            $this->collection[$key] = $value;
        }
        return $this;
    }
1067048
public function fromArray($arr)
    {
        $class = $this->getModel();
        foreach ($arr as $element) {
            /** @var $obj BaseObject */
            $obj = new $class();
            $obj->fromArray($element);
            $this->append($obj);
        }
    }
452391
private function toCollection(array $array)
    {
        $collection = new IniCollection([]);
        foreach ($array as $k => $v) {
            if (is_array($array[$k]))
                $collection->set($k, $this->toCollection($array[$k])->toArray());
            else
                $collection->set($k, $v);
        }
        return $collection;
    }
983594
public function validate($arr)
    {
        $returnValue = new ValidatorResult();
        $this->currentNode = 'root';

        try {
            $this->validateSchemaBeginsWithRootKey(new CustomArrayObject($this->schema));

            if ($this->strictMode) {
                $this->validateExcessiveKeysAbsent(new CustomArrayObject($this->schema['root']), $arr);
            }

            $this->validateNode('root', new CustomArrayObject($this->schema), $arr);
        } catch (Exception $exc) {
            $this->getLogger()->error($exc->getMessage());

            $returnValue->setError($exc->getCode(), $this->getCurrentNode(), $exc->getMessage());
            $returnValue->setLog($this->getLogger()->getLog());
        }

        return $returnValue;
    }
881842
public function even(): ArrayCollection
    {
        $items = [];
        $pos = 0;

        foreach ($this->items as $key => $value) {
            if ($pos % 2 === 0) {
                $items[$key] = $value;
            }
            $pos++;
        }

        return new static($items);
    }
684372
public function transform($value): Collection
    {
        Assert::nullOrIsArray($value);

        if (empty($value)) {
            return new ArrayCollection();
        }

        return new ArrayCollection($this->taxonRepository->findBy(['code' => $value]));
    }
1029405
public static function array_compare(&$arr1, &$arr2) {
		// Obviously bad data.
		if (! \is_array($arr1) || ! \is_array($arr2)) {
			return false;
		}

		$length = \count($arr1);

		// Length mismatch.
		if (\count($arr2) !== $length) {
			return false;
		}

		// Different keys, we don't need to check further.
		if (\count(\array_intersect_key($arr1, $arr2)) !== $length) {
			return false;
		}

		// We will ignore keys for non-associative arrays.
		if (
			(cast::array_type($arr1) !== 'associative') &&
			(cast::array_type($arr2) !== 'associative')
		) {
			return \count(\array_intersect($arr1, $arr2)) === $length;
		}

		// Check each item.
		foreach ($arr1 as $k=>$v) {
			if (! isset($arr2[$k])) {
				return false;
			}

			// Recursive?
			if (\is_array($arr1[$k]) && \is_array($arr2[$k])) {
				if (! static::array_compare($arr1[$k], $arr2[$k])) {
					return false;
				}
			}
			elseif ($arr1[$k] !== $arr2[$k]) {
				return false;
			}
		}

		return true;
	}
72580
function(arr) {
        if (Array.prototype.from) return Array.from(new Set(arr));
        return arr.filter(function(v,i,a) {
          return i === a.indexOf(v);
        });
      }
1217054
public function asc(array $collection)
    {
        $count = count($collection);

        if ($count < 2) {
            return $collection;
        }

        $leftCollection = array();
        $rightCollection = array();

        reset($collection);

        $sortPivot = key($collection);
        $pivot = array_shift($collection);

        foreach ($collection as $key => $value) {
            if ($value < $pivot == $this->forwardSort) {
                $leftCollection[$key] = $value;
            } else {
                $rightCollection[$key] = $value;
            }
        }

        return array_merge($this->asc($leftCollection),
            array($sortPivot => $pivot),
            $this->asc($rightCollection));
    }
8620
protected static function isArrayObject($arr)
    {
        foreach(array_keys($arr) as $key) {
            if (!is_int($key)) {
                return true;
            }
        }

        return false;
    }
197970
private function copyValue($value)
    {
        if (is_array($value)) {
            return $this->copyArray($value, true);
        }
        if (!is_object($value)) {
            return $value;
        }
        if ($value instanceof Collection) {
            return new ArrayCollection($this->copyArray($value->toArray(), false));
        }
        if ($value instanceof \Traversable) {
            throw new ClonerException(sprintf('Traversable class "%s" is not supported.', ClassUtils::getClass($value)));
        }

        return $this->cloneObject($value, false);
    }
694697
public function marshalCollection(array $collection, $category = null)
    {
        if (!$this->isSorted) {
            $this->sortStrategies();
        }
        $marshalledCollection = array();
        foreach ($collection as $toMarshal) {
            $marshalledCollection[] = $this->marshal($toMarshal, $category);
        }

        return $marshalledCollection;
    }
687751
public function natsort(): Collection
    {
        $index = 0;
        $items = $this->items;

        foreach ($items as &$item) {
            $item = [$index++, $item];
        }

        uasort($items, function ($a, $b) {
            $result = strnatcmp($a[1], $b[1]);

            return $result === 0 ? $a[0] - $b[0] : $result;
        });

        foreach ($items as &$item) {
            $item = $item[1];
        }

        return new static($items);
    }
121514
public static function remove_empty($arr)
    {
        if (empty($arr)) {
            return null;
        }
        foreach ($arr as $key => $value) {
            if (is_array($value)) {
                $arr[$key] = self::remove_empty($value);
            } else {
                if (empty($value)) {
                    unset($arr[$key]);
                } else {
                    $arr[$key] = $value;
                }
            }
        }
        return $arr;
    }
817308
public static function unique($arr)
	{
		// filter out all duplicate values
		return array_filter(
			$arr,
			function ($item)
			{
				// contrary to popular belief, this is not as static as you think...
				static $vars = array();

				if (in_array($item, $vars, true))
				{
					// duplicate
					return false;
				}
				else
				{
					// record we've had this value
					$vars[] = $item;

					// unique
					return true;
				}
			}
		);
	}