tags:

views:

69

answers:

3

How to find out that foo is at the position of 2?: array('boo', 'moo', 'foo');

+9  A: 
$key = array_search("foo", $array);
Chacha102
+5  A: 

print_r ( array_search ( 'value',$array_from ) );

pavun_cool
+2  A: 

If you want to find the keys for all occurences of 'foo' (if you know there will be duplicates) then use:

$result = array_keys( $yourArray, 'foo' );

This will return an array with all corresponding keys. You see, array_search will only return the key of the first occurence. Be aware of this.

fireeyedboy