0

How to How to check PHP multiple Conditional Statements in one. Somethig like this :

if($image_ex == "{gif|jpg|png|jpeg}"){
     //something
}
Megi
  • 113
  • 13

1 Answers1

4

You need to use a regex, use multiple conditions, or put the values in an array. I'd use http://php.net/manual/en/function.in-array.php.

if (in_array($image_ex , array('gif', 'jpg', 'png', 'jpeg'))) {

A regex approach could be:

if(preg_match('/^(?:gif|png|jpe?g)$/', $image_ex)){

or the long multiple conditions approach:

if($image_ex == "gif" || $image_ex == "jpg" || etc..){
chris85
  • 23,846
  • 7
  • 34
  • 51