This should do the trick.
<cfscript>
function arrayFind(arr,str)
{
for(i=1; i lte arraylen(arr); i=i+i)
{
if (not comparenocase(arr[i], str))
{ return i; }
}
return 0;
}
</cfscript>
Just use it like...
#arrayFind(arrayToSearch, StringToSearchFor)#
On Another not... If you use indexOf() like James suggested, there are a
couple of issues to worry about...
1) it's case sensitive like he said but he doesn't meant you have to type it
as indexOf... he means 'myvalue' is not the same as 'MYVALUE' when searching
with indexOf()
2) you'll need to add 1 to any result before using that index in CF since
Java arrays/lists start at 0 and CF arrays/lists start at 1
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: James Holmes [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 27, 2007 4:06 AM
To: CF-Talk
Subject: Re: Push values into an array -> Search on array
As CF arrays are java lists:
<cfset myindex = imageinformation.indexOf(priority)>
This is of course an undocumented feature that could break in the future -
use at your own risk. It's also case-sensitive.
On 9/27/07, Stivn .. <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> i have questions to array functions.
>
> Step 1:
> I have pushed some sql-values into an array:
>
> <cfloop query="pushintoarray">
> <cfset updateimage = #updateimage#+1>
> <cfset imageinformation[#updateimage#] = #pushintoarray.OBJECTID#>
> </cfloop>
>
> Now i want to compare the values of the array with an existing variable
(f.e. "priority").
>
> Question:
> How can i discover the array-number which have the value of the variable
"priority"?
>
> Thank you in advance for your help.
--
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289610
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4