Returns all the key-value pairs from the array whose key has the specified prefix.

@param array $values
@param string $prefix
@param bool $removePrefixFromKeys
@return array
552180
private function extractValues(array $values, $prefix, $removePrefixFromKeys = true)
    {
        if (empty($values)) {
            return array();
        }

        $validKeys = array_filter(array_keys($values), function($name) use ($prefix) {
            return (0 === strpos($name, $prefix));
        });

        $results = array_intersect_key($values, array_flip($validKeys));
        if (!$removePrefixFromKeys) {
            return $results;
        }

        return array_combine(
            array_map(function($key) use ($prefix) {
                return str_replace($prefix, '', $key);
            }, array_keys($results)), $results
        );
    }
20894
private function applyPrefix(array $array, $prefix = null)
    {
        if ($prefix === null) {
            return $array;
        }

        $result = [];
        foreach ($array as $key => $value) {
            $result[$prefix . self::PREFIX_GLUE . $key] = $value;
        }

        return $result;
    }
16139
public function getKeys($prefix = null, $type = null)
    {
        $map = $this->getMap();
        $keys = array_keys($map);

        $result = [];

        foreach ($keys as $key) {
            if (null === $prefix || (is_string($prefix) && strpos($key, $prefix))) {
                if (0 === $type) {
                    $result[$key] = $key;
                } else {
                    $v = $map[$key];

                    if ($type === $v->getType()) {
                        $result[$key] = $key;
                    }
                }
            }
        }

        return $result;
    }
302742
public function addPrefix($values, $prefix)
    {
        $new_values = array();
        foreach ($values as $s) {
            $new_values[] = $prefix . $s;
        }

        return $new_values;
    }
1236638
public static function flattenArray(array $array, $prefix = '')
    {
        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result = $result + self::flattenArray($value, $prefix.$key.'.');
            } else {
                $result[$prefix.$key] = self::normalizeValue($value);
            }
        }

        return $result;
    }
1005646
public function getQueryFields($usePrefix = false, $prefix = '')
    {
        $fields = $this->fields;

        if ($usePrefix) {
            $prefix = (empty($prefix) ? $this->getTable() : $prefix);
            $fields = array();
            foreach ($this->fields as $field) {
                $fields[] = $prefix . '.' . $field;
            }
        }

        return implode(', ', $fields);
    }
1222704
protected static function get_prefixed_keys(Memcached $connection, $prefix) {
        $connkeys = $connection->getAllKeys();
        if (empty($connkeys)) {
            return array();
        }

        $keys = array();
        $start = strlen($prefix);
        foreach ($connkeys as $key) {
            if (strpos($key, $prefix) === 0) {
                $keys[] = substr($key, $start);
            }
        }
        return $keys;
    }
988744
public function getKey(string $prefix = ''): string
    {
        $value = $this->getData();
        if (!is_array($value)) {
            $key = $value ?: '';
        } else {
            if (!empty($this->getAttributes())) {
                $flipped = array_flip($this->getAttributes());
                $value = array_intersect_key($value, $flipped);
            }

            $key = str_replace('=', '_', http_build_query($value, '', '_'));
        }

        return hash(self::ALGORITHM, $prefix.'_'.$key);
    }
738752
private function processHitResultsRecurse($results, $prefix=null) {
        if(!is_array($results)) {
            return [$prefix => $results];
        }

        $ret = [];
        foreach($results as $key=>$result) {
            // Flatten arrays.
            $sub_prefix = is_null($prefix) ? $key:"$prefix.$key";
            $ret = array_merge($ret, $this->processHitResultsRecurse($result, $sub_prefix));
        }
        return $ret;
    }
1174655
protected function compileValues(array $values, $prefix = '')
    {
        $retVal = [];
        foreach ($values as $key => $value) {
            if (is_array($value)) {
                $retVal = array_merge($retVal, $this->compileValues($value, $prefix . $key . '.'));
            } else {
                $retVal['{{' . $prefix . $key . '}}'] = $value;
            }
        }
        return $retVal;
    }
50141
public static function getAll( $prefix = NULL, $excludePrefix = NULL )
	{
		$prefix	= strtoupper( $prefix );
		$length	= strlen( $prefix );
		if( $length	< 2 )
			throw new InvalidArgumentException( 'Prefix "'.$prefix.'" is to short.' );
		$map	= get_defined_constants();
		if( $prefix ){
			foreach( $map as $key => $value )
			{
				if( $key[0] !== $prefix[0] )
					unset( $map[$key] );
				else if( $key[1] !== $prefix[1] )
					unset( $map[$key] );
				else if( substr( $key, 0, $length ) !== $prefix )
					unset( $map[$key] );
#				remark( $prefix." - ".$key." - ".(int)isset( $map[$key] ) );
			}
		}
		if( $excludePrefix ){
			if( substr( $excludePrefix, 0, $length ) !== $prefix )
				$excludePrefix	= $prefix.$excludePrefix;
			foreach( $map as $key => $value ){
				if( substr( $key, 0, strlen( $excludePrefix ) ) === $excludePrefix )
					unset( $map[$key] );
			}
		}
		return $map;
	}
41140
public function prefixValues(array $arguments, $prefix)
    {
        $skip = ['id', 'ID'];

        return array_map(function ($key) use ($prefix, $skip) {
            if (in_array($key, $skip)) {
                return $key;
            }

            return "{$prefix}{$key}";
        }, $arguments);
    }
820273
private function containsKeyPrefix($keyPrefix)
    {
        foreach ($this->values as $k => $v) {
            if (0 === strpos($k, $keyPrefix)) {
                return true;
            }
        }

        return false;
    }
400461
public static function removePrefix($string, $prefix)
    {
        if (self::startsWith($string, $prefix)) {
            return substr($string, mb_strlen($prefix));
        }
        return $string;
    }
341702
protected static function prepareBinding(array $replacements = [], $prefix = '{', $suffix = '}')
    {
        $replacements = Arr::dot($replacements);
        $bindings     = [];

        foreach ($replacements as $key => $value) {
            $bindings["{$prefix}{$key}{$suffix}"] = $value;
        }

        return $bindings;
    }
924328
protected function prefix($value, $prefix)
    {
        if (is_array($value)) {
            return array_map(function ($item) use ($prefix) {
                return $this->prefix($item, $prefix);
            }, $value);
        }

        return $prefix . $value;
    }
316837
Properties getProperties(String prefix, boolean removePrefix) {
		Properties result = new Properties();
		for (String key : getPropertyNames()) {
			if (key.startsWith(prefix)) {
				result.put((removePrefix) ? key.substring(prefix.length()) : key, getProperty(key));
			}
		}
		return result;
	}