Remove values from the beginning of an array using comparison

@param array $arr The source array
@param mixed $match Values matching this value will be removed
@param boolean $strict Whether or not to use strict comparison
@return array
329825
public static function shiftValues(
        array $arr,
        $match = false,
        bool $strict = false
    ): array
    {
        $func = Compare::getMethod($strict);
        $len = count($arr);
        while ($len > 0 && call_user_func($func, reset($arr), $match)) {
            array_shift($arr);
            $len--;
        }
        return $arr;
    }
1251778
public static function before($arr, $i) {
		$res = [];
		foreach($arr as $k=>$v) {
			if($k === $i)
				return $res;
			$res[$k] = $v;
		}
		return $res;
	}
128895
function removeA(arr) {
  var what,
    a = arguments,
    L = a.length,
    ax;
  while (L > 1 && arr.length) {
    what = a[--L];
    while ((ax = arr.indexOf(what)) !== -1) {
      arr.splice(ax, 1);
    }
  }
  return arr;
}
840106
public static function keyOf(array $set, $match) {
        $return = null;
        $isArray = array();

        foreach ($set as $key => $value) {
            if ($value === $match) {
                $return = $key;
            }

            if (is_array($value)) {
                $isArray[] = $key;
            }
        }

        if (!$return && $isArray) {
            foreach ($isArray as $key) {
                if ($value = static::keyOf($set[$key], $match)) {
                    $return = $key . '.' . $value;
                }
            }
        }

        return $return;
    }
386246
private function _filter(array $matches)
    {
        $filters = explode('|', $matches[0]);
        $var = $filters[0];
        unset($filters[0]);
        foreach ($filters as $filter) {
            $params = explode(':', $filter);
            $filterName = $params[0];
            unset($params[0]);
            $array = 'array(';
            foreach ($params as $param) {
                $array .= $param . ',';
            }
            $array = trim($array, ',') . ')';
            $var = 'getFilter(\'' . $filterName . '\')->setOptions(' . $array . ')->filter(' . $var . ')';
        }
        return $var;
    }
608795
public function match(Parser $parser, $uri, $params = array(), $strict = false)
    {
        // match literal string from start to end
        $length = strlen($this->token);
        if (substr($uri, 0, $length) === $this->token) {
            $uri = substr($uri, $length);
        }

        // when there's no match, just return null if strict mode is given
        else if ($strict) {
            return null;
        }

        return array($uri, $params);
    }
191305
public static function cleanArray(array &$arr)
    {
        foreach ($arr as $k => $v) {
            if (is_array($v)) {
                self::cleanArray($arr[$k]);
            } else {
                $arr[$k] = stripslashes($v);
            }
        }
    }
604363
protected function getMatchArgs(array $match)
    {
        // Remove the first element, the matching regex
        array_shift($match);

        // Iterate through the arguments and remove any unwanted slashes
        foreach ($match as &$arg) {
            $arg = trim($arg, '/');
        }

        return $match;
    }
931522
public static function ucfirst($str, bool $strict=false) {
		ref\mb::ucfirst($str, $strict);
		return $str;
	}
70631
public static function reduce(array $carry, Match $match)
    {
        if (!isset($carry[$match->index]) || $carry[$match->index]->score < $match->score) {
            $carry[$match->index] = $match;
        }

        return $carry;
    }
348995
private static function fromArray($arr, &$result = [], $limit = false, $offset = 1)
    {
        if (is_null($arr)) {
            return $arr;
        }
        if (false === $limit) {
            $limit = strlen($arr) - 1;
            $result = [];
        }
        if ('{}' != $arr) {
            do {
                if ('{' != $arr{$offset}) {
                    preg_match("/(\\{?\"([^\"\\\\]|\\\\.)*\"|[^,{}]+)+([,}]+)/", $arr, $match, 0, $offset);
                    $offset += strlen($match[0]);
                    $result[] = ('"' != $match[1]{0} ? $match[1] : stripcslashes(substr($match[1], 1, -1)));
                    if ('},' == $match[3]) {
                        return $offset;
                    }
                } else {
                    $innerResult = [];
                    $offset = self::fromArray($arr, $innerResult, $limit, $offset + 1);

                    $result[] = $innerResult;
                }
            } while ($limit > $offset);
        }

        return $result;
    }
1361048
public function removeDuplicates($strict = false) {
		$field = $strict ? 'message' : 'summary';

		$query = $this->find();
		$options = [
			'fields' => ['type', $field, 'count' => $query->func()->count('*')],
			'conditions' => [],
			'group' => ['type', $field],
			//'having' => $this->alias . '__count > 0',
			//'order' => ['created' => 'DESC']
		];
		$logs = $query->find('all', $options)->disableHydration()->toArray();

		$count = 0;
		foreach ($logs as $key => $log) {
			if ($log['count'] <= 1) {
				continue;
			}
			$options = [
				'fields' => ['id'],
				'keyField' => 'id',
				'valueField' => 'id',
				'conditions' => [
					'type' => $log['type'],
					$field => $log[$field],
				],
				'order' => ['created' => 'DESC']
			];
			$entries = $this->find('list', $options)->toArray();

			// keep the newest entry
			$keep = array_shift($entries);
			if ($entries) {
				$this->deleteAll(['id IN' => $entries]);
			}
			$count += $this->updateAll(['count = count + ' . count($entries)], ['id' => $keep]);
		}

		return $count;
	}
29281
public static function arrayContainsArrayItems($arr)
    {
        if (!self::isValidArray($arr)) {
            return false;
        }

        foreach ($arr as $item) {
            if (self::isValidArray($item)) {
                return true;
            }
        }

        return false;
    }
1019716
private static function clearNonMatched($match_results){
    return array_filter($match_results, function($el){
      $keep = true;
      if($el === "" || (is_array($el) && empty($el))|| $el === null|| $el === array("")){
        $keep = false;
      }

      return $keep;
    });
  }
465919
public function cleanUri($uri, $strict = false)
	{
		$filters = $this->config['uri_filter'];
		$filters = is_array($filters) ? $filters : array($filters);

		if ($strict)
		{
			$uri = preg_replace(array("/\.+\//", '/\/+/'), '/', $uri);
		}

		return $this->clean($uri, $filters);
	}
240637
public static function inArrayRecursive($needle, $haystack, $strict = false)
	{
		foreach ($haystack as $value)
		{
			if (! $strict and $needle == $value)
			{
				return true;
			}
			elseif ($needle === $value)
			{
				return true;
			}
			elseif (is_array($value) and static::inArrayRecursive($needle, $value, $strict))
			{
				return true;
			}
		}

		return false;
	}
472673
public function compare($strict = false)
    {
        return CompareHelper::compare($this->compare1, $this->operator, $this->compare2, $strict);
    }