ArrayFindAll()
These functions searches the array for the specified object and return the positions of all occurrence of this values.
ArrayFindAll( array=array, value_or_closure=any );
Returns: Array
| Argument | Description |
|---|---|
|
array
array,
required
|
edit
The array to search in |
|
value_or_closure
any,
required
|
edit
Alias: object, value, closure, function, udf, callback |
Examples
editFind all the positions of all occurrences of a string in array
fruitArray = [ 'apple', 'kiwi', 'banana', 'orange', 'mango', 'kiwi' ];
favoriteFruits = arrayFindAll( fruitArray, 'kiwi' );
dump( favoriteFruits ); // [ 2, 6 ]
notKiwis = arrayFindAll( fruitArray,
function( el ){
return arguments.el neq 'kiwi';
});
dump( notKiwis ); // [1,3,4,5]
See also
- Arrays
- array.findAll()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)