PHP : If...Else...Query

Posted by Rachel on Stack Overflow See other posts from Stack Overflow or by Rachel
Published on 2010-03-16T21:07:25Z Indexed on 2010/03/16 21:21 UTC
Read the original article Hit count: 149

Filed under:

I am executing this statement under while (($data=fgetcsv($this->fin,5000,";"))!==FALSE)

Now what I want in else loop is to throw exception only for data value which did not satisfy the if condition. Right now am displaying the complete row as I am not sure how to throw exception only for data which does not satisfy the value.

Code

if ((strtotime($data[11]) &&strtotime($data[12])&&strtotime($data[16]))!==FALSE 
&& ctype_digit($data[0]) && ctype_alnum($data[1]) && ctype_digit($data[2]) 
&& ctype_alnum($data[3]) && ctype_alnum($data[4]) && ctype_alnum($data[5]) 
&& ctype_alnum($data[6]) && ctype_alnum($data[7]) && ctype_alnum($data[8]) 
&& $this->_is_valid($data[9]) && ctype_digit($data[10]) && ctype_digit($data[13]) 
&& $this->_is_valid($data[14]))
{
     //Some Logic
}
else
{
    throw new Exception ("Data {$data[0], $data[1], $data[2], $data[3],
    $data[4], $data[5], $data[6], $data[7],
    $data[8], $data[9], $data[10], $data[11], $data[12],
    $data[13], $data[14], $data[16]} is not in valid format");
}

Guidance would be highly appreciated as to how can I throw exception only for data which did not satisfy the if value.

© Stack Overflow or respective owner

Related posts about php