Randomly return one of the values provided
careful: only works with numerical keys (0 based!)

@param array $array
@param int|null $minPosition
@param int|null $maxPosition
@param bool $integerKeys
@return mixed
545064
public static function arrayValue($array, $minPosition = null, $maxPosition = null, $integerKeys = false) {
		if (empty($array)) {
			return null;
		}
		if ($integerKeys) {
			$max = count($array) - 1;
			return $array[static::int(0, $max)];
		}
		$keys = array_keys($array);
		$values = array_values($array);
		$max = count($keys) - 1;
		return $values[static::int(0, $max)];
	}
561480
public function slice($array, $n, $position = null)
    {
        if ($position === null) {
            return $this->operator('$slice', [$array, $n]);
        } else {
            return $this->operator('$slice', [$array, $position, $n]);
        }
    }
157698
public static function filterKeys ($array, $keys)
		{
			if (is_array($array))
			{
				$return = [];
				if (!is_array($keys))
					$keys = [ $keys ];
				foreach ($keys as $key)
					if (isset($array[ $key ]))
						$return[ $key ] = $array[ $key ];

				return $return;
			}

			return null;
		}
1074581
public static function get(array $array, $key = null, $default = null)
    {
        if ($key === null) {
            return $array;
        }

        if (isset($array[$key])) {
            return static::value($array[$key]);
        }

        foreach (explode('.', (string) $key) as $segment) {
            if (! array_key_exists($segment, $array)) {
                return static::value($default);
            }

            $array = $array[$segment];
        }

        return $array;
    }
532348
protected function get(array $array, $key)
    {
        if (isset($array[$key])) {
            return $array[$key];
        }

        foreach (explode(".", $key) as $part) {
            if (!is_array($array) or !isset($array[$part])) {
                return null;
            }

            $array = $array[$part];
        }

        return $array;
    }
119724
public static function sGet($array, $key, $default = null)
    {
        $value = self::get($array, $key);
        return !empty($value) ? $value : $default;
    }
293126
public static function keyFlattening($array, $keys = []) {
		if (is_array($array)) {
			$result = [];
			foreach ($array as $key => $value) {
				$tmp_keys = $keys;
				$tmp_keys [] = $key;
				$result = array_merge($result, static::keyFlattening($value,$tmp_keys));
			}
			return $result;
		}

		$key = array_shift($keys);
		return [
			empty($keys) ? $key : sprintf('%s[%s]', $key, implode ('][', $keys)) => $array,
		];
	}
390538
public int getMinValueIndex(double[] array) {

        int index = 0;
        double min = Integer.MAX_VALUE;

        for (int i = 0; i < array.length; i++) {
            if (array[i] < min) {
                min = array[i];
                index = i;
            }
        }

        return index;
    }
342795
public static function getMaxKeyLength(array $array)
    {
        $maxKeyLength = '0';
        foreach ($array as $key => $value) {
            $currentLength = static::getVisibleStringLength($key);

            if ($currentLength > $maxKeyLength) {
                $maxKeyLength = $currentLength;
            }
        }

        return $maxKeyLength;
    }
651156
public static function findElementsByKey($array, $key, &$targetArray = null, $prefix = "") {

        if ($array instanceof AssociativeArray) {
            $array = $array->toArray();
        }

        if (!$targetArray)
            $targetArray = array();

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

            if ($itemKey === $key) {
                $targetArray[substr($prefix . "." . $key, 1)] = $value;
            } else if (is_array($value) || $value instanceof AssociativeArray) {

                if (is_numeric($itemKey)) {
                    $newPrefix = $prefix . "[" . $itemKey . "]";
                } else {
                    $newPrefix = $prefix . "." . $itemKey;
                }

                ArrayUtils::findElementsByKey($value, $key, $targetArray, $newPrefix);
            }
        }

        return $targetArray;

    }
326821
public static function getSubArrayFromArrayByKeys(array $array, array $keys)
    {
        $result = [];

        foreach ($keys as $key) {
            if (array_key_exists($key, $array)) {
                $result[$key] = $array[$key];
            }
        }

        return $result;
    }
1016739
public static function randomize(array $array): array
    {
        for ($i = 0, $c = count($array); $i < $c - 1; $i++) {
            $j = rand($i + 1, $c - 1);
            list($array[$i], $array[$j]) = [$array[$j], $array[$i]];
        }

        return $array;
    }
627679
public static function ksortRecursive(array &$array, $sortFlags = SORT_REGULAR)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $effect = &$array;
        ksort($effect, $sortFlags);

        foreach ($effect as &$value) {
            if (is_array($value)) {
                ksort($value, $sortFlags);
            }
        }

        return $effect;
    }
1120502
public function arrayRand($array, $num = 1) {
    $keys = array_keys($array);
    $numKeys = sizeof($keys);
    if($num == 1) {
      return $keys[$this->int(0, $numKeys-1)];
    }

    for($i=0; $i < $num; $i++) {
      $picked[] = $keys[$this->int(0, $numKeys-1)];
    }
    return $picked;
  }
317802
private function _arrayShiftAssoc(array &$array)
    {
        if (empty($array)) {
            return null;
        }
        
        // Make sure that the array variable is pointing to the beginning of the array
        reset($array);
        
        // Now, get the first key and first value
        $firstKey   = key($array);
        $firstValue = current($array); // equivalent to $array[$firstKey]
        
        unset($array[$firstKey]);
        
        return [$firstKey, $firstValue];
    }
1271414
protected static function arrayGet(array $array, $key)
    {
        $key = strtolower($key);
        $array = array_change_key_case($array, CASE_LOWER);

        if (!array_key_exists($key, $array)) {
            throw new TokenException(
                sprintf('Did not find key %s in array: %s', json_encode($key), json_encode($array))
            );
        }

        return $array[$key];
    }
871891
private function isAssoc($array) {
	$allIntegerKeys = true;
	foreach ($array as $key => $value) {
		if(!is_integer($key)) {
			$allIntegerKeys = false;
			break;
		}
	}

	return $allIntegerKeys === false;
}