Filter an Array by given prefixes.

@param array $data
@param array $prefixes

@return array the filtered array or $arrData if $prefix is empty
433111
public function filterByPrefixes(array $data = [], $prefixes = [])
    {
        $extract = [];

        if (!\is_array($prefixes) || empty($prefixes)) {
            return $data;
        }

        foreach ($data as $key => $value) {
            foreach ($prefixes as $prefix) {
                if ($this->container->get('huh.utils.string')->startsWith($key, $prefix)) {
                    $extract[$key] = $value;
                }
            }
        }

        return $extract;
    }
505275
public static function mergePrefixData($data, $prefixData)
    {
        $prefixGroups = $prefixData['prefix-groups'];

        foreach ($data["partitions"] as $index => $partition) {
            foreach ($prefixGroups as $current => $old) {
                $serviceData = Env::search("services.{$current}", $partition);
                if (!empty($serviceData)) {
                    foreach ($old as $prefix) {
                        if (empty(Env::search("services.{$prefix}", $partition))) {
                            $data["partitions"][$index]["services"][$prefix] = $serviceData;
                        }
                    }
                }
            }
        }

        return $data;
    }
631786
public static function values($array, $prefix = null)
    {
        $values = array_values($array);

        if (! empty($prefix)) {
            $values = static::prefix($values, $prefix);
        }

        return $values;
    }
849699
public function extra(array $data, $prefix = '')
    {
        $this->initInternals();

        return $this->blueprintSchema->extra($data, $prefix);
    }
855328
private function filterData(array $data)
    {
        $pattern = '/^' . str_replace('%', '.*', trim($this->likeExpr, "'")) . '$/';
        $newData = [];

        foreach ($data as $row) {
            if (preg_match($pattern, $row['Name'])) {
                $newData[] = $row;
            }
        }

        return $newData;
    }
521380
public function filterColumns(array $data) {
        $testCols = array_fill_keys($this->info(Zend_Db_Table_Abstract::COLS), null);
        return array_intersect_key($data, $testCols);
    }
758554
public static List<String> keys(String prefix, Map<String, String> data) {
        logger.debug("get keys for {}", prefix);
        // matches: 'prefix.xxx...' | 'prefix."xxx.t"...'
        Pattern keyPattern = Pattern.compile("^" + Pattern.quote(prefix) + "\\.(\"[^\"]+\"|[^\\.]+).*$");
        return data.keySet().stream()
                .map(key -> {
                    Matcher m = keyPattern.matcher(key);
                    return m.matches() ? m.group(1)
                            : null;
                }).filter(k -> k != null)
                .distinct()
                .collect(Collectors.toList());
    }
140614
protected function matchOr($data, array $matchers)
    {
        foreach ($matchers as $matcher) {
            if ($matcher($data)) {
                return true;
            }
        }
        return false;
    }
1148841
public static function prettyPrint($data, $prefix = '')
    {
        $php = '[' . PHP_EOL;
        if (is_array($data) and array_diff_key($data, array_keys(array_keys($data)))) {
            foreach ($data as $key => $value) {
                $php .= $prefix . '  ' . var_export($key, true) . ' => ';
                if (is_array($value)) {
                    $php .= self::prettyPrint($value, $prefix . '  ');
                } else {
                    $php .= var_export($value, true);
                }
                $php .= ',' . PHP_EOL;
            }
        } else {
            foreach ($data as $value) {
                $php .= $prefix . '  ';
                if (is_array($value)) {
                    $php .= self::prettyPrint($value, $prefix . '  ');
                } else {
                    $php .= var_export($value, true);
                }
                $php .= ',' . PHP_EOL;
            }
        }
        return $php . $prefix . ']';
    }
904168
function filter($data = array())
    {
        if (! is_array($data)) {
            return $data;
        }
        // first apply the filters to the ROOT
        if (isset($this->filters[self::SELECTOR_ROOT])) {
            /* @var $rootFilters FilterSet */
            $rootFilters = $this->filters[self::SELECTOR_ROOT];
            $data = $rootFilters->applyFilters($data);
        }
        foreach ($data as $key => $value) {
            $data[$key] = $this->filterItem($data, $key);
        }
        return $data;
    }
493043
protected function createFilter(array $data = null)
    {
        $filter = new static();
        if ($data !== null) {
            $filter->setData($data);
        }
        return $filter;
    }
406317
public static function nulls(array $data, $keys = null)
    {
        if ($keys === null) {
            $keys = array_keys($data);
        }

        if (!Arrays::isArray($keys)) {
            $keys = array($keys);
        }

        foreach ($keys as $key) {
            if (array_key_exists($key, $data) && empty($data[$key])) {
                $data[$key] = null;
            }
        }

        return $data;
    }
972141
private function order(array $data)
    {
        $filteredData = $this->filterOrderable($data);

        if (!empty($filteredData)) {
            uasort(
                $filteredData,
                function (OrderedNormalizerInterface $a, OrderedNormalizerInterface $b) {
                    return $a->getOrder() > $b->getOrder();
                }
            );

            return array_merge($filteredData, array_diff_key($data, $filteredData));
        }

        return $data;
    }
418503
private static function arrayFlatten($array, $prefix = '')
    {
        $result = array();
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result = $result + self::arrayFlatten($value, $prefix . $key . '.');
            } else {
                $result[$prefix . $key] = trim(preg_replace('/\s+/', ' ', $value));
            }
        }
        return $result;
    }
1134214
protected function prefixKeys($prefix, array $data)
	{
		$result = [];
		
		foreach($data as $k => $v)
		{
			$result[$prefix . $k] = $v;
		}
		
		return $result;
	}
165271
protected function searchFilter( array $data ) {

		$keyword = ( ! empty( $_REQUEST['s'] ) ) ? (string) trim( $_REQUEST['s'] ) : false;

		if ( ! $keyword ) {
			return $data;
		}

		$filtered_data = [];
		foreach ( $data as $_ => $val ) {
			if ( $this->atLeastOneKeyword( $keyword, $val ) ) {
				$filtered_data[] = $val;
			}
		}

		return $filtered_data;
	}
721071
public static function filter_input(array $data, array $filters)
    {
        $gump = self::get_instance();

        return $gump->filter($data, $filters);
    }