NotionCommotion Posted October 14, 2020 Share Posted October 14, 2020 Is there a better way to have array_intersect_key() return only non-NULL values? Thanks function stripAssociatedArray(array $array, array $keys, bool $removeNull=false):array { $array = array_intersect_key($array, array_flip($keys)); return $removeNull?array_filter($array, fn($value) => !is_null($value)):$array; } Quote Link to comment https://forums.phpfreaks.com/topic/311598-array_intersect_key-without-null-values/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.