Skip to content

Commit 5e5bc04

Browse files
[11.x] Feature: Array reject (#54638)
* add arr filter as alias for arr where * add arr reject method * remove filter as an alias for where * Update Arr.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent b9b8a57 commit 5e5bc04

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Illuminate/Collections/Arr.php

+12
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,18 @@ public static function where($array, callable $callback)
930930
return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
931931
}
932932

933+
/**
934+
* Filter the array using the negation of the given callback.
935+
*
936+
* @param array $array
937+
* @param callable $callback
938+
* @return array
939+
*/
940+
public static function reject($array, callable $callback)
941+
{
942+
return static::where($array, fn ($value, $key) => ! $callback($value, $key));
943+
}
944+
933945
/**
934946
* Filter items where the value is not null.
935947
*

0 commit comments

Comments
 (0)