Skip to main content
nikos101
Inspiring
June 24, 2009
Question

Better way to get the index of where the string is without using a mass of if else logic.

  • June 24, 2009
  • 1 reply
  • 337 views

Hi

if I have an array like so

['price'],

['user'],

['time']

I want to set a bunch of predifined variables like so

<cfset PriceIndex = 1>

<cfset UserIndex = 2>

<cfset TimeIndex = 3>

Now I'm only showing 3 variables andactuaally have 12.

Since my array can have string variables in any order (but the strings don't change)

is there a better way to get the index of where the string is without using a mass of if else logic.

Many thanks.

    This topic has been closed for replies.

    1 reply

    nikos101
    nikos101Author
    Inspiring
    June 24, 2009

    hmm

    this looks like it

    http://www.jeffryhouser.com/index.cfm/2006/1/20/ColdFusion-supports-ArrayindexOf-sort-of

    nikos101
    nikos101Author
    Inspiring
    June 24, 2009

    yerp