Jump to content

|| operator won't work?


esbenp

Recommended Posts

Hello,

i have a wierd problem, or maybe i'm just too tired to se it for myself :-)

 

$patterns = array(
                    "firstname"=>"/^[A-Za-Z-æøå]{2,64} [A-Za-zæøå]?$/",
                    "lastname"=>"/^[A-Za-zæøå-]{2,32}$/",
                    "adress"=>"/^[A-Za-zæøå\.]{5,32} [0-9]{1,5} [A-Za-zæøå0-9\.]?$/",
                    "city"=>"/^[A-Za-zæøå]{2,32}$/",
                    "postnr"=>"/^[0-9]{4,4}$/",
                    "tlf"=>"/^\+?[0-9]{8,10}$/",
                    "email"=>"[A-Za-z0-9._]{2,32}@[A-Za-z0-9]{2,32}\.[A-Za-z]{2,5}"
                    );

        foreach($_POST as $key => $value) {
            if($key !== "shipping" || $key !== "payment" || $key !== "next_x" || $key !== "next_y") {
                if(preg_match($patterns[$key], $value)) {
                    // do stuff..
                }
            }             
        }

 

It keeps ignoring my || operators, and checks the "trash" of my $_POST array?

Does anyone see why?

And please comment on my patterns, if you'd like :-)

 

Link to comment
https://forums.phpfreaks.com/topic/190723-operator-wont-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.