johnsmith153 Posted February 5, 2011 Share Posted February 5, 2011 if(in_array("b", $array)) { } The above checks to see if a value is present in an array, but how do I then retrieve the array key value from the matching value? $array[0] = "a"; $array[1] = "b"; $array[2] = "c"; So in the example, the answer is 1 (array key 1). Quote Link to comment Share on other sites More sharing options...
sunfighter Posted February 5, 2011 Share Posted February 5, 2011 It's doing what you want - it's telling that b is in the array. Use array_search() to find out where. http://www.php.net/manual/en/function.array-search.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.