diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f26c744..4c18d9b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#new) * Added support for custom `FormFlash` save locations + * Added a new `Utils::arrayLower()` method for lowercasing arrays 1. [](#improved) * Use new `Utils::getSupportedPageTypes()` to enforce `html,htm` at the front of the list [#2531](https://github.com/getgrav/grav/issues/2531) 1. [](#bugfix) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index ba7528bce..7e040c894 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -323,6 +323,17 @@ abstract class Utils return (object)array_merge((array)$obj1, (array)$obj2); } + /** + * Lowercase an entire array. Useful when combined with `in_array()` + * + * @param array $a + * @return array|false + */ + public static function arrayLower(Array $a) + { + return array_combine(array_map('strtolower', $a), $a); + } + /** * Simple function to remove item/s in an array by value *