Pulls out the options hash from $array if any.

@internal DO NOT remove the reference on $array.
@param array &$array An array
@return array A valid options array
12354
public static function extractAndValidateOptions(array &$array)
	{
		$options = array();

		if ($array)
		{
			$last = &$array[count($array)-1];

			try
			{
				if (self::isOptionsHash($last))
				{
					array_pop($array);
					$options = $last;
				}
			}
			catch (ActiveRecordException $e)
			{
				if (!Arry::isHash($last))
					throw $e;

				$options = array('conditions' => $last);
			}
		}

		// Check if and order was given
		if (!array_key_exists("order", $options)) {

			// A static configurator?
			if (static::$defaultOrder) {

				// Use that
				$options['order'] = static::$defaultOrder;

			} else {

				// Use my pk's
				$options['order'] = join(' ASC, ', static::table()->pk) . ' ASC';

			}

		}

		return $options;
	}
1165285
function _parseOptions($array)
    {
        foreach ($array as $key => $value) {
            if (isset($this->options[$key])) {
                $this->options[$key] = $value;
            }
        }

        /* Include additional fields if they exist */
        if(!empty($this->options['db_fields'])){
            if(is_array($this->options['db_fields'])){
                $this->options['db_fields'] = join($this->options['db_fields'], ', ');
            }
            $this->options['db_fields'] = ', '.$this->options['db_fields'];
        }
    }
1172623
public static function drop(array &$array, $key)
    {
        $keys = explode('.', $key);
        $last = array_pop($keys);
        foreach($keys as $key) {
            if(!isset($array[$key])) {
                return false;
            }
            $array = &$array[$key];
        }

        if(isset($array[$last])) {
            unset($array[$last]);
            return true;
        }

        return false;
    }
28059
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['action']                = LanguageUtility::toString($this->action);
        $array['responseContent']       = $this->responseContent;
        $array['username']              = $this->username;
        $array['password']              = $this->password;
        $array['ticket']                = $this->ticket;
        $array['accessToken']           = $this->accessToken;
        $array['accessTokenExpiresAt']  = LanguageUtility::orZero($this->accessTokenExpiresAt);
        $array['accessTokenDuration']   = LanguageUtility::orZero($this->accessTokenDuration);
        $array['refreshToken']          = $this->refreshToken;
        $array['refreshTokenExpiresAt'] = LanguageUtility::orZero($this->refreshTokenExpiresAt);
        $array['refreshTokenDuration']  = LanguageUtility::orZero($this->refreshTokenDuration);
        $array['idToken']               = $this->idToken;
        $array['grantType']             = LanguageUtility::toString($this->grantType);
        $array['clientId']              = $this->clientId;
        $array['clientIdAlias']         = $this->clientIdAlias;
        $array['clientIdAliasUsed']     = $this->clientIdAliasUsed;
        $array['subject']               = $this->subject;
        $array['scopes']                = $this->scopes;
        $array['properties']            = LanguageUtility::convertArrayOfArrayCopyableToArray($this->properties);
    }
1146570
static protected function flattenArray( $array )
    {
        if ( !is_array( $array ) )
        {
            return array( $array );
        }

        $arrayFlatten = array();
        while( !empty( $array ) )
        {
             $item = array_shift( $array );
             if ( is_array( $item ) )
                 $array = array_merge( $item, $array );
             else
                 $arrayFlatten[] = $item;
        }
        return $arrayFlatten;
    }
1113416
public static function arrayToKey(array $array): string {
        $result = "";
        \array_walk_recursive($array, function ($key, $value) use (&$result) {
            $result .= $key . $value;
        });
        return $result;
    }
596005
public static function flatten(array $array)
    {
        $result = array();

        array_walk_recursive($array, function ($value, $key) use (& $result) {
            if (is_numeric($key) or is_object($value)) {
                $result[] = $value;
            } else {
                $result[$key] = $value;
            }
        });

        return $result;
    }
914386
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['action']               = LanguageUtility::toString($this->action);
        $array['accessToken']          = $this->accessToken;
        $array['accessTokenExpiresAt'] = LanguageUtility::orZero($this->accessTokenExpiresAt);
        $array['scopes']               = $this->scopes;
        $array['properties']           = LanguageUtility::convertArrayOfArrayCopyableToArray($this->properties);
    }
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;
    }
1268883
private function camelizeKeys(array $array)
    {
        $camelized = array();

        foreach ($array as $key => $value) {
            $camelized[$this->camelize($key)] = is_array($value)
                ? $this->camelizeKeys($value)
                : $value;
        }

        return $camelized;
    }
253766
private function serializeArrayOrTable(array $array)
    {
        $assoc = false;
        $index = 0;
        $values = [];

        foreach ($array as $key => $value) {
            // We already know the array is associative, serialize both the key
            // and the value ...
            if ($assoc) {
                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                // Otherwise, if the key matches the index counter it is sequential,
                // only serialize the value ...
            } elseif ($key === $index++) {
                $values[] = $this->serializeField($value);

                // Otherwise, we've just discovered the array is NOT sequential,
                // Go back through the existing values and add the keys ...
            } else {
                foreach ($values as $k => $v) {
                    $values[$k] = $this->serializeShortString($k) . $v;
                }

                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                $assoc = true;
            }
        }

        return ($assoc ? 'F' : 'A') . $this->serializeByteArray(
                implode('', $values)
            );
    }
11225
public function arrayKey(array $array, $key = 'key'): array
    {
        $out = [];

        foreach ($array as $id => $item) {
            if (isset($item[$key])) {
                $out[$item[$key]] =  $item;
            } else {
                $out[$id] =  $item;
            }
        }

        return $out;
    }
1200967
protected function removeSlashes($array)
    {
        $fnc = function ($value) use (&$fnc) {
            if (is_array($value)) {
                return array_map($fnc, $value);
            }

            return stripslashes($value);
        };

        if (version_compare(phpversion(), '6.0.0-dev', '<') && get_magic_quotes_gpc()) {
            $array = array_map($fnc, $array);
        }

        return $array;
    }
1078684
private function kSortRecursive(array &$array)
    {
        foreach ($array as &$current) {
            if (is_array($current) &&
                $this->kSortRecursive($current) === false
            ) {
                return false;
            }
        }
        return ksort($array);
    }
1028884
public static function arrayFlatten($array)
    {
        $flatten = array();
        foreach ($array as $key => $inner) {
            if (is_array($inner)) {
                foreach ($inner as $inner_key => $value) {
                    $flatten[$inner_key] = $value;
                }
            } else {
                $flatten[$key] = $inner;
            }
        }

        return $flatten;
    }
920431
private function trimArray($array)
    {
        foreach ($array as $key => $value) {
            // Do not attemp to trim array variables, boolean variables, or the proxy password
            // Trimming a boolean value (as a string) may not produce the expected output, so pass it through as-is
            if (!is_array($value) && !is_bool($value) && $key !== 'proxy_password') {
                $array[$key] = trim($value);
            }
        }
        return $array;
    }
1367879
private static function getValueList(array $array): array
    {
        foreach ($array as $i => $attr)
            $array[$i] = (is_array($attr) ? self::getValueList($attr) : self::getValue($attr));

        return $array;
    }