For the given array only keep elements that are in the list of given $values

array:keep_values(ARRAY $array, ARRAY $values, BOOL $strict_match=FALSE) : ARRAY

# note: this function keeps key->value association
array:keep_values(["foo","bar","zoo"],["foo","zoo"])
#=> [ 0 => "foo", 2 => "zoo" ]

array:keep_values(["name" => "foo", "email" => "bar"], ["bar"])
#=> [ "email" => "bar" ]

# note: by default it uses non-strict match (==) where 1 == "1"
array:keep_values(["1",2],[1])
#=> [ "1" ]

# note: you can use strict match (===) where 1 is not equal to "1"
array:keep_values(["1",2],[1], true)
#=> []

Copyright ©2013-2022 SunSed®. All rights reserved.