How can I add an index (1,2,3) to an array like this:
$errors['success'] = false; //0
$errors['#errOne'] = "Enter a valid username"; //1
$errors['#errTwo'] = "Enter a valid email";//2
$errors['#errThree'] = "Enter a valid password";//3
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.
Just use the integer index instead of the string index.
If your order doesn’t matter, it’s easier yet to not specify an index, and PHP will push it onto the array.
Looking at your structure though, I would suggest not keeping such a mix of things in your array. You should have an array for your list of errors, and a separate value for whether or not something was successful. (Is the definition of successful no errors? If so, you can check for that.) Maybe something like this instead?