Possible Duplicate:
PHP get index of last inserted item in array
My array is generated the following way:
$_SESSION['add_fail_urls'][] = $_REQUEST['url'];
How do I get a number value of the automatically assigned key []?
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.
Should do the trick. If you want to ensure that you don’t get any notices about the
add_fail_urlsnot existing, then use the following instead:Edit: I might’ve misinterpreted your post (as of @des comment), as you might want the actual index of the added element instead of the number of elements. If so, here’s a solution brought to you from @romaninsh in the linked question: