tags:

views:

49

answers:

2
$string = array('A','B','C','A','B','C');

For example first instance of C in $string would be 2

Is there a simpler way to do this than doing a complex loop in php?

+3  A: 

Use array_search() function. (http://php.net/array%5Fsearch)

Cesar
super! thank you
Chad
+1  A: 

Array_search() will do exactly what you want.

http://us.php.net/manual/en/function.array-search.php

Abinadi