maze
maze

Reputation: 3

check if one element in array has value

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.

Upvotes: 0

Views: 350

Answers (1)

nobody
nobody

Reputation: 10645

if( in_array(1, $error) ) {
    //we have at least one error
}

Upvotes: 3

Related Questions