Jump to content

[SOLVED] if statements


The Little Guy

Recommended Posts

instead of doing this:
[code]if($file == '.jpg'||$file == '.jpeg'||$file == '.gif'||$file == '.png'||$file == '.tiff'){[/code]

is there a way to do it something like this? This doesn't work, so I was just wondering if I could do something like this.
[code]if($file == ('.jpg'||'.jpeg'||'.gif'||'.png'||'.tiff')){[/code]
Link to comment
https://forums.phpfreaks.com/topic/30946-solved-if-statements/
Share on other sites

No, the second "if" is not correct syntax.

You could use a switch statement instead of the if:
[code]<?php
switch ($file) {
  case '.jpg':
  case '.jpeg':
  case '.gif':
  case '.png':
  case '.tiff':
//
//  your code here
//
  break;
}
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/30946-solved-if-statements/#findComment-142793
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.