preg match - php search within string for word? -


i'm using php's preg_match determine value of string.
code ever prints 1 or 2.

why aren't last 2 cases of if statement ever matched?

$atype = strtolower($userdata['user_type']);   // let data :: company introducer  if ($atype == "individual introducer" || $atype == "individualintroducer" ||      (preg_match('/i/',$atype) , preg_match('/int/',$atype)) ) {         $atype = 1 ;  } elseif ($atype == "individual investor" || $atype == "individualinvestor" ||                    (preg_match('/i/',$atype) , preg_match('/inv/',$atype)) ) {         $atype = 2;  } elseif ($atype == "company introducer" || $atype == "companyintroducer" ||            (preg_match('/c/',$atype) , preg_match('/int/',$atype)) ){         $atype = 3;  } elseif ($atype == "company investor" || $atype == "companyinvestor" ||            (preg_match('/c/',$atype) , preg_match('/inv/',$atype)) ){         $atype = 4;  }  echo $atype; 

you need explain question in better way.

but guess data assumed company introducer.

so matches condition first if block. ex:

in company introducer preg_match return true.

if($atype == "individual introducer" || $atype == "individualintroducer" || (preg_match('/i/',$atype) , preg_match('/int/',$atype))  ){     $atype =1 ; } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -