Filters an array applying a callback function

@param array $array Target array
@param \Closure A callback function that returns a filtered array
@return array
320103
public static function filterArray(array $array, Closure $callback)
    {
        foreach ($array as $index => $collection) {
            $array[$index] = call_user_func($callback, $collection);
        }

        return $array;
    }
570472
private function filterUniqueRole($array)
    {
        $arrayRewrite = array();
        foreach ($array as $key => $parent)
        {
            foreach ($parent as $role)
            {
                if (!isset($arrayRewrite[$key]) || !in_array($role, $arrayRewrite[$key]))
                {
                    $arrayRewrite[$key][] = $role;
                }
            }
        }
        return $arrayRewrite;
    }
5134
public function filter(&$array) {
        while(list($key, $var) = each($array)) {
            if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || '' . intval($key) == "$key")) {
                if (is_string($var)) {
                    $array[$key] = stripslashes($var);
                }
                if (is_array($var))  {
                    $array[$key] = $this->filter($var);
                }
            }
        }
        return $array;
    }
682355
public static function pluck($array, $key)
    {
        return array_map(
            function ($v) use ($key) {
                return is_object($v) ? $v->$key : $v[$key];

            },
            $array
        );
    }
1343267
public static function implode(Array $array, $glue, Closure $closure) {
    return implode($glue, array_map($closure, (array) $array, array_keys($array)));
  }
146354
public function array_map( $array, $callback ) {
		$array = $this->get_array_value( $array );

		return array_map( function ( $d ) use ( $callback ) {
			return is_callable( $callback ) ? $callback( $d ) : ( is_string( $callback ) && method_exists( $d, $callback ) ? $d->$callback() : null );
		}, $array );
	}
1269565
public static function cleanupArray($array)
    {
        $newArray = [];

        $array = static::toArray($array);

        foreach ($array as $key => $val) {

            if (is_array($val)) {
                $val = static::cleanupArray($val);
            } else {
                $val = trim($val);
                if (!$val) {
                    continue;
                }
            }

            $newArray[$key] = $val;
        }

        return $newArray;
    }
256751
static public function callback($array, $callback)
	{
	    if (is_array($array)) foreach ($array as $k=>$v) {
	        if (is_array($v)) {
	            $array[$k] = static::callback($v, $callback);
	        } else {
	            $array[$k] = $callback($v);
	        }
	    }
	    return $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;
        }
776918
public function arrayFilterRecursive(array $array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                /** @var $value array */
                $value = count($value) === 1 && array_key_exists(0, $value) && is_string($value[ 0 ]) &&
                $this->variable->isEmpty(trim($value[ 0 ])) ? $value[ 0 ] : $this->arrayFilterRecursive($value);
            }
        }

        return array_filter($array, function ($value) {
            return ! $this->variable->isEmpty($value) &&
                ! (is_string($value) && $this->variable->isEmpty(trim($value)));
        });
    }
477765
public function filter(\Closure $callback)
    {
        $result = [];
        foreach ($this->value as $entity) {
            if ($callback($entity)) {
                $result[] = $entity;
            }
        }

        return $result;
    }
660551
private function narrowArray(array $array, string $key = null)
    {
        if ($key) {
            $key .= '--';
        }

        $result = [];

        foreach ($array as $index => $value) {
            if (is_array($value)) {
                $result = array_merge($result, $this->narrowArray($value, $key . $index));
            } else {
                $result[$key . $index] = $value;
            }
        }

        return $result;
    }
935937
public static function last($array, callable $callback = null, $default = null)
    {
        if (null === $callback) {
            return 0 === count($array) ? Mixed::value($default) : end($array);
        }

        return static::first(array_reverse($array, true), $callback, $default);
    }
415062
public function filter(Closure $closure): self
    {
        $filter = new Iterator\CustomFilterIterator($this->getIterator(), [$closure]);

        return new self(iterator_to_array($filter));
    }
711239
public function unsetFilter($array, $keys) {
		if(is_array($array)) {
			if(!is_array($keys)) {
				$keys = array(
					$keys 
				);
			}
			foreach($keys as $key) {
				if(array_key_exists($key, $array)) {
					unset($array[$key]);
				}
			}
		}
		return $array;
	}
157698
public static function filterKeys ($array, $keys)
		{
			if (is_array($array))
			{
				$return = [];
				if (!is_array($keys))
					$keys = [ $keys ];
				foreach ($keys as $key)
					if (isset($array[ $key ]))
						$return[ $key ] = $array[ $key ];

				return $return;
			}

			return null;
		}
383897
public function filter(Closure $callback)
    {
        $filtered_map = new static;

        foreach ($this->items as $key => $item) {
            if ($callback($item) === true) {
                $filtered_map->setItem($key, $item);
            }
        }

        return $filtered_map;
    }