Filter List: Unique By Key | ARRAY_UNIQUEBY
Syntax
ARRAY_UNIQUEBY( [value], [key] )
Parameters
value
An ARRAY to filter. Should be an ARRAY of MAPS / OBJECTS.
key
A path into each item to pull the value to check for uniqueness.
For more information on the path syntax used by instalink.io see the dedicated documentation on that subject.
Return Value
Returns an ARRAY of items in VALUE that have a unique value at KEY.Description
Get unique items in an ARRAY based on the value at a path. If multiple items in the ARRAY have the same key, the first one found is kept and the rest discarded.Examples
ARRAY_UNIQUEBY([], "a.b") # returns []
# VALUE is [["a" => 1, "b" => 2], ["a" => 3, "b" => 4], ["a"=> 1, "b" => 5]]
ARRAY_UNIQUEBY(VALUE, "a") # returns [["a" => 1, "b" => 2], ["a" => 3, "b" => 4]]
# VALUE is [["a" => ["b" => 1], "c" => 3], ["a" => ["b" => 1], "c" => 4], ["a" => ["b" => 2], "c" => 5]]
ARRAY_UNIQUEBY(VALUE, "a.b") # returns [["a" => ["b" => 1], "c" => 3], ["a" => ["b" => 2], "c" => 5]]
ARRAY_UNIQUEBY(null, "a.b") # returns []
# VALUE is [["a" => 1, "b" => 2], ["a" => 3, "b" => 4], ["a"=> 1, "b" => 5]]
ARRAY_UNIQUEBY(VALUE, null) # returns []