Find the given value in An array using a closure

@param callable $func

@return bool Returns true if the given value is found, false otherwise
510131
public function exists(callable $func)
    {
        $isExists = false;

        foreach ($this->elements as $key => $value) {
            if ($func($key, $value)) {
                $isExists = true;
                break;
            }
        }

        return $isExists;
    }
118102
public function reduce(callable $func, $initial)
    {
        if (\is_array($this->pipeline)) {
            return \array_reduce($this->pipeline, $func, $initial);
        }

        foreach ($this as $value) {
            $initial = $func($initial, $value);
        }

        return $initial;
    }
1162702
public function delete(string $pattern, $func)
    {
        $method = strtoupper(__FUNCTION__);
        if (is_array($func)) {
            if ($this->isPatternMatches($pattern)) {
                $this->middleware = $func['middleware'];
            }
            $func = end($func);
        }

        return $this->match($method, $pattern, $func);
    }
146820
public function contains($field, $value)
    {
        return function ($object) use ($field, $value) {
            return false !== strpos(ClosureExpressionBuilder::getObjectFieldValue($object, $field), $value);
        };
    }
1238907
public function map(callable $func = null): self
    {
        if (null === $func) {
            return $this;
        }

        return parent::map($func);
    }
983928
public function isCallable($c)
    {
        if (is_string($c)) {
            return false;
        }
        if (is_object($c) && is_callable($c)) {
            return true;
        }

        return is_array($c) && isset($c[0]) && is_object($c[0]) && is_callable($c);
    }
299010
static function iterate($func)
	{
		$db = \App::get('db');

		$query = "SELECT cn FROM `#__xgroups`;";

		$db->setQuery($query);

		$result = $db->loadColumn();

		if ($result === false)
		{
			return false;
		}

		foreach ($result as $row)
		{
			call_user_func($func, $row);
		}

		return true;
	}
82155
public static function call($func, $full, $fsencoding = '') {
        if (function_exists($func)) {
            $full = self::conv_to($full, $fsencoding);
            return $func($full);
        }
        return false;
    }
573902
public static function find(array $data, callable $callback = null, $keepKey = false, $offset = null, $limit = null)
    {
        $results = [];
        $i = 0;
        $c = 0;

        $callback = null === $callback ? 'is_null' : $callback;

        foreach ($data as $key => $value) {
            // If use global function, send only value as argument.
            if (is_string($callback)) {
                $r = $callback($value);
            } else {
                $r = $callback($value, $key);
            }

            if ($r) {
                if ($offset !== null && $offset > $i) {
                    continue;
                }

                if ($limit !== null && $c >= $limit) {
                    break;
                }

                $results[$key] = $value;
                $c++;
            }

            $i++;
        }

        return $keepKey ? $results : array_values($results);
    }
381220
public function post(string $pattern, $func)
    {
        $method = strtoupper(__FUNCTION__);
        if (is_array($func)) {
            if ($this->isPatternMatches($pattern)) {
                $this->middleware = $func['middleware'];
            }
            $func = end($func);
        }
        if (!$func instanceof \Closure) {
            return $this->override($pattern, $func, false, $method);
        }

        return $this->match($method, $pattern, $func);
    }
267058
public function callback($func) {
        if (!$this->_isValid) {
            return $this;
        }
        $this->_isValid = (bool) $func($this->_unsafeVar);
        return $this;
    }
1274747
private static function mapNumeric($value, \Closure $func)
    {
        if (is_numeric($value)) {
            $value = $func($value);
        } elseif (is_array($value)) {
            array_walk_recursive($value, function (&$value) use ($func) {
                $value = self::mapNumeric($value, $func);
            });
        }

        return $value;
    }
754121
protected function findConfiguration($value, \Closure $func)
    {
        /** @var AbstractPageRouteConfiguration $configuration */
        foreach ($this->all() as $configuration) {
            if ($func($configuration, $value)) {
                return $configuration;
            }
        }

        return null;
    }
459760
function first(callable $closure = null) {
        if($closure === null) {
            if(empty($this->data)) {
                return null;
            }
            
            $keys = \array_keys($this->data);
            return ($this->data[$keys[0]] ?? null);
        }
        
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                return $val;
            }
        }
        
        return null;
    }
261124
public function find($callback)
    {
        foreach ($this->value as $value) {
            if (call_user_func($callback, $value)) {
                return $value;
            }
        }
        
        return null;
    }
630446
public function map(Closure $func)
    {
        $this->guardAgainstInvalidGivenType();
        $elements = $this->collection->map($func)->toArray();
        $newCollection = $this->create();
        foreach ($elements as $key => $element) {
            try {
                $newCollection->set($key, $element);
            } catch (InvalidArgumentException $e) {
                // do nothing, because the mapped item is not instance of type
            }
        }

        return $newCollection;
    }
1022429
final public function each($func)
    {
        foreach ($this->elements as $inx => $val)
        {
            call_user_func($func,$inx,$val);
        }
        return $this;
    }