Simone
02/21/2023, 7:26 PMMyka Forrest
02/21/2023, 7:28 PMarrayIsDefined() insteadSimone
02/21/2023, 7:30 PMMyka Forrest
02/21/2023, 7:30 PMMyka Forrest
02/21/2023, 7:30 PMsteveduke
02/21/2023, 7:46 PMisDefined('array[1]') is not going to cause a breaking error.
If itβs not defined it will return false. If it is defined it will return true.
e.g. isDefined('wobblybobly[345]') will return false if you have never defined it.
can you explain what you are trying to solve? Is it any of these?
- is the array defined
- is there one element in the array
- is the first element of the array something you expect to be defined
If we know more specifically what you are attempting to solve we may be able to help.
And as previously recommended, it will help when you look up the documentation for the syntax.Adam Cameron
arrayIsDefined. When it didn't work, did you look at the docs? No. Always do that first before asking anyone else for help: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-a-b/arrayisdefined.htmlSimone
02/21/2023, 8:09 PMSimone
02/21/2023, 8:48 PMSimone
02/21/2023, 8:48 PM<cfset s = []>
<cfset x = isArray(s) AND !ArrayIsEmpty(s[2]) ? s[2] : 0>
<cfdump var="#x#">Simone
02/21/2023, 8:48 PMMyka Forrest
02/21/2023, 8:49 PMarrayIsEmpty() does what you are expecting it to do.Myka Forrest
02/21/2023, 8:49 PMSimone
02/21/2023, 8:52 PMMyka Forrest
02/21/2023, 8:52 PMarrayIsDefined(s,2)Myka Forrest
02/21/2023, 8:52 PMEvil Ware
02/21/2023, 8:52 PMthisOldDave
02/22/2023, 8:51 AMsteveduke
02/22/2023, 2:43 PM<cfscript>
myArray = [1,2,3,4];
x = isNumeric(myArray?.1)?myArray[1]:0;
echo(x);
</cfscript>thisOldDave
02/22/2023, 3:08 PMsteveduke
02/22/2023, 3:35 PMwriteOutput(!myArray.len()?0:isNumeric(myArray[1])?myArray[1]:0);Adam Cameron
a has element i, one just needs to call arrayIsDefined(a, i).
It's well documented and there's no mystery to it. One just has to take the minimum amount of time learning one's craft.spills
02/27/2023, 7:13 PMMyka Forrest
02/27/2023, 7:14 PMspills
02/27/2023, 7:19 PMMyka Forrest
02/27/2023, 7:21 PMspills
02/27/2023, 7:37 PMAdam Cameron
like this. Three back-ticks if it's a block:
like thisspills
02/27/2023, 8:12 PMspills
02/27/2023, 8:12 PM