# Fastest way to lookup a value associated with a string

**URL:** <https://forum.kirupa.com/t/fastest-way-to-lookup-a-value-associated-with-a-string/326033>\
**Category:** Uncategorized\
**Created:** [November 19, 2011, 2:11am UTC](https://forum.kirupa.com/t/fastest-way-to-lookup-a-value-associated-with-a-string/326033 "2011-11-19T02:11:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [November 19, 2011, 2:11am UTC](https://forum.kirupa.com/t/fastest-way-to-lookup-a-value-associated-with-a-string/326033/1 "2011-11-19T02:11:38Z")

</div>

Looking at this extremely complex example here:

```php

var value:int;
var a:String=("dog");
var b:String=("cat");
var c:String=("bear");

decode(b);

function decode(string:String){
    if(string=="dog"){
        value=1;
    }else if(string=="cat"){
        value=2;
    }else if(string=="bear"){
        value=3;
    }
}

```

My goal is to simply feed in a string, and use the predefined corresponding integer i have associated.

I would like to know the absolute fastest way this is achieved.
