You can also use the underlying Java object's indexOf() method:
<cfset theIndex = myArray.indexOf("XYZ")>
Just remember to add 1 to the result.
On Tue, Jun 24, 2008 at 6:08 AM, Bobby Hartsfield <[EMAIL PROTECTED]> wrote:
> This will either return 0 if the string isn't found or the array position in
> which it was found
>
> <cfscript>
> function searchArray(arr,str)
> {
> var retVal = 0;
> for(i=1; i lte arraylen(arr); i=i+1)
> {
> if (arr[i] is str)
> {
> retVal = i;
> break;
> }
> }
> return retVal;
> }
> </cfscript>
>
> Just use it like....
>
> #searchArray(myArray,'XYZ')#
--
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308006
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4