I have this array in PHP:
array(
[0] => array( 'username' => 'user1' )
[1] => array( 'username' => 'user2' )
)
If I have the ‘username’ string how can I get the index value as a number?
Example, if I have ‘user1’ how can I get 0?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have a 2D array, like in your example, you’ll need to customise things a little:
If you wanted to search in just one particular field, you could alter the function to something like this: