0

i have an array $error which tells me if any of my post vars produced an error or not:

Array
(
    [pers_anrede] =>  1
    [pers_titel] => 1
    [pers_vorname] => 
    [pers_nachname] => 
    [pers_vorwahl] => 1 
    [pers_telefon] => 1
    [pers_email] => 
)

(where 1 means that the element has an error)

what is the most effective way to find out whether any errors at all are present? if all elements in my array are set to 0, i want to continue doing something else. if there is at least one error present, i want to display a general error message.

2
  • are you trying to search a value in an array? stackoverflow.com/questions/2693310/… Commented Sep 9, 2011 at 13:57
  • the values can only be 1 or 0. if there is at least one value of "1" i want to say something like "there has been an error" ... if however no errors where detected (meaning all elements in the array will be 0), everything is fine. Commented Sep 9, 2011 at 13:58

1 Answer 1

3
if( in_array(1, $error) ) {
    //we have at least one error
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.