From 9291bfbecb1d754bfc2a23ad31380f95919bdc51 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 30 Jul 2020 22:48:24 +0000 Subject: [PATCH] [UTIL] Add Common::array_remove_keys --- src/Util/Common.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Util/Common.php b/src/Util/Common.php index f0f4d04c9f..f34ed16101 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -33,6 +33,7 @@ namespace App\Util; use App\Core\DB\DB; use App\Core\Router; use App\Core\Security; +use Functional as F; use Symfony\Component\Security\Core\User\UserInterface; abstract class Common @@ -106,6 +107,14 @@ abstract class Common // return in_array($str, array_keys($paths)); } + /** + * Remove keys from the _values_ of $keys from the array $from + */ + public static function array_remove_keys(array $from, array $keys, bool $strict = false) + { + return F\filter($from, function ($e) use ($keys, $strict) { return in_array($e, $keys, $strict); }); + } + /** * An internal helper function that converts a $size from php.ini for * file size limit from the 'human-readable' shorthand into a int. If