Core Function LastIndexOfValueAny
LastIndexOfValueAny( <array>, <needle>, <strict>, <ignoreCase>, <skipStringKeys> )
Contents |
Description
Checks if a value (from an array of values) exists in an array and returns the index of the last occurrence of the value (from the value array).
Parameters
array
The array to use.
needle
An array to search for its values.
strict
Optional; If true the the array value and the needle must be same TYPE such as both Int32s.
Note - If "strict" is true when the needle is a Regex then it will require all the values to be STRING or else it will not match.
Default: false
ignoreCase
Optional; Flag to choose if the search will be case sensitive or case insensitive
True: Ignore case and match with case insensitivity
False: Case must be an exact match
Default: false
skipStringKeys
Optional; Flag to choose if the search will ignore all keys in the array that are not numeric
True: Ignore all non-numeric keys such as "Cat" and "Dog" but match with keys like 0 1 2 3 4
False: Match all keys regardless of what they are made of
-1: Match only non-numeric keys and nothing else such as only match "Cat" and "Dog" but not numbers like 0 1 2 3 4
Default: false
Return Value
Success: Returns integer index if the last occurrence of the value (from an array of values) was located in the array section or a string of the index key if the last occurrence of the value (from an array of values) was found in the dictionary section.
Failure: Returns null (It has to return null since it is the only way to make sure that even every possible key match was invalid).
Remarks
None.
Example
my $arr = array("One", "Two", "Three", "Four", "One"); $pos = LastIndexOfValueAny($arr, array("One", "Two")); say "Positon is: $pos"; // 4 my $arr = array("One" => "Cat", "Two" => "Dog", "Three" => "Sheep"); $pos = LastIndexOfValueAny($arr, array("Dog", "Two")); say "Positon is: $pos"; // Two $pos = LastIndexOfValueAny($arr, array("Sheep", "Two")); say "Positon is: $pos"; // Three