lundi 30 août 2021

How to Check if php variable have numeric or from certain string characters using php? [duplicate]

I want if $pro_case is not either a numeric (any numeric) value or string from these names only the answer will be FALSE else must be TRUE response from this Code.

$pro_case = "Australia";
   if(!is_numeric($pro_case) || $pro_case != "Africa" ||  "Europe" || "North America" || "South 
    America" || "Australia"){
    echo FALSE;
   }else{
    echo TRUE;
  }

I only got FALSE response from this Code even Australia is in there.

EDIT: $pro_case must be either any numeric value or

"Africa" ||  "Europe" || "North America" || "South 
        America" || "Australia"

to get only TRUE answer.

I tried with in_array method but the problem is the numeric vale can be any number. What could be the problem?

Aucun commentaire:

Enregistrer un commentaire