Recursively remove elements and from an array using a callback function

@param array $arr
@param callable $callback
@return null
559204
public static function filter(array $arr, callable $callback)
    {
        foreach ($arr as $key => $value) {

            if (is_array($value) && count($value) > 0) {
                $arr[$key] = static::filter($value, $callback);
            }

            if (!call_user_func($callback, $arr[$key], $key)) {
                unset($arr[$key]);
            }

        }

        return $arr;
    }
244129
protected function handleCallback($callback, array $args = [])
    {
        $response = null;

        // Check if $callback is a closure.
        if ($callback instanceof \Closure || is_array($callback)) {
            $response = call_user_func($callback, $args);
        } elseif (is_string($callback)) {
            if (false !== strpos($callback, '@') || class_exists($callback)) {
                // We use a "ClassName@method" syntax.
                // Let's get a class instance and call its method.
                $callbackArray = $this->handleClassCallback($callback);
                $response = call_user_func($callbackArray, $args);
            } else {
                // Used as a classic callback function.
                $response = call_user_func($callback, $args);
            }
        }

        return $response;
    }
465305
function (array, callback) {
    for (var len = 0; len < array.length; len++) {
      if (callback(array[len]) === false) {
        return false
      }
    }
    return true
  }
1327
public static function filter(array $arr, callable $callback): array
    {
        $arrResult = [];

        foreach ($arr as $index => $value) {
            if ($callback($value, $index) === true) {
                $arrResult[] = $value;
            }
        }

        return $arrResult;
    }
239179
public static function deferArr(&$e, $callback, $args) {
		if (!is_callable($callback)) {
			if (is_string($callback) && !function_exists($callback)) {
				throw new \Exception("function '{$callback}' not exist");
			}
			throw new \Exception("this is not callable");
		}
		$e = new self($e, $callback, $args);
	}
484728
public static function clean( $array = null, $callback = null )
    {
        $_result = ( empty( $array ) ? array() : ( !is_array( $array ) ? array($array) : $array ) );

        if ( null === $callback || !is_callable( $callback ) )
        {
            return $_result;
        }

        $_response = array();

        foreach ( $_result as $_item )
        {
            $_response[] = call_user_func( $callback, $_item );
        }

        return $_response;
    }
670883
public static function last($array, callable $callback = null, $default = null) {
        if (is_null($callback)) {
            return empty($array) ? Str::value($default) : end($array);
        }

        return static::first(array_reverse($array, true), $callback, $default);
    }
649324
public function detach($event, $callback)
    {
        if (null !== $callback) {
            $oid = $this->hashCallable($callback);
            if (isset($this->callable_map[$event][$oid])) {
                $callback = $this->callable_map[$event][$oid];
                unset($this->callable_map[$event][$oid]);
            }
        } else {
            unset($this->callable_map[$event]);
        }
        return parent::detach($event, $callback);
    }
1003556
public static function filterRecursive($array, $callback = null)
	{
		foreach ($array as &$value)
		{
			if (is_array($value))
			{
				$value = $callback === null ? static::filterRecursive($value) : static::filterRecursive(
																					  $value,
																						  $callback
				);
			}
		}

		return $callback === null ? array_filter($array) : array_filter($array, $callback);
	}
1224991
private function remove(string $selector, callable $callback = null): self {
        $nodes = $this->document()->find($selector);

        foreach ($nodes as $node) {
            if (is_null($callback) || $callback($node)) {
                $node->remove();
            }
        }

        return $this;
    }
1290622
public function each(callable $callback)
    {
        $array = $this->getArrayCopy();
        foreach ($array as $key => $value) {
            $callback($value, $key, $array);
        }
    }
1321626
public static function where($array, \Closure $callback)
        {
            $filtered = array();

            foreach ($array as $key => $value) {
                if (call_user_func($callback, $key, $value)) {
                    $filtered[$key] = $value;
                }
            }

            return $filtered;
        }
1024553
public static function map(array $arr, callable $callback): array
    {
        $arrResult = [];

        foreach ($arr as $index => $value) {
            $arrResult[] = $callback($value, $index);
        }

        return $arrResult;
    }
483760
public static function only(array $arr, callable $callback): bool
    {
        $arrLength = 0;

        foreach ($arr as $index => $value) {
            if ($callback($value, $index) === true) {
                $arrLength++;
            }
        }

        return $arrLength === 1;
    }
881161
public static function filterRecursive($array, callable $callback): array
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $value = static::filterRecursive($value, $callback);
            }
        }

        return array_filter($array, $callback);
    }
205851
public static function arrayMap(callable $callback, array $array)
    {
        foreach ($array as $key => $value) {
            $array[$key] = \call_user_func($callback, $value, $key);
        }

        return $array;
    }
101721
public static function remove_value($arr, $delval = '')
    {
        if (empty($arr)) {
            return null;
        }
        foreach ($arr as $key => $value) {
            if (is_array($value)) {
                $arr[$key] = self::remove_value($value, $delval);
            } else {
                if ($delval === $value) {
                    unset($arr[$key]);
                } else {
                    $arr[$key] = $value;
                }
            }
        }
        return $arr;
    }