Returns whether there exists an item in the array at the selected index.
arrayIndexExists(array, index)
→ returns boolean
array.indexExists(index)
In this example, the index we are checking exists in the array so the check returns true.
myArray=[];
myArray[1]='one';
myArray[2]='two';
myArray[3]='three';
myArray[4]='four';
myArray[5]='five';
result = arrayIndexExists(myArray, 3);
writeOutput(result);
Expected Result: true
In this example, there is no element at the index we're checking so the check returns false.
myArray=[];
myArray[1]='one';
myArray[2]='two';
// no element at index 3
myArray[4]='four';
myArray[5]='five';
result = arrayIndexExists(myArray, 3);
writeOutput(result);
Expected Result: false
In this example, the array we are searching is empty so the check returns false.
myArray=[];
result = arrayIndexExists(myArray, 3);
writeOutput(result);
Expected Result: false
In this example, the index we are checking exists in the array so the check returns true.
myArray=[];
myArray[1]='one';
myArray[2]='two';
myArray[3]='three';
myArray[4]='four';
myArray[5]='five';
result = myArray.indexExists(3);
writeOutput(result);
Expected Result: true
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.