0
$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?

asked Oct 29, 2009 at 1:37

2 Answers 2

3

Use array_search() function. (http://php.net/array_search)

answered Oct 29, 2009 at 1:40
0
1

Array_search() will do exactly what you want.

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

answered Oct 29, 2009 at 1:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.