The Little Guy Posted December 17, 2006 Share Posted December 17, 2006 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 More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 No, the second "if" is not correct syntax.You could use a switch statement instead of the if:[code]<?phpswitch ($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 More sharing options...
BillyBoB Posted December 17, 2006 Share Posted December 17, 2006 try this maybe ?[code]<?php$array = array(".jpg",".jpeg",".gif",".png",".tiff");if(in_array($file,$array)) ?>[/code] Link to comment https://forums.phpfreaks.com/topic/30946-solved-if-statements/#findComment-142794 Share on other sites More sharing options...
The Little Guy Posted December 17, 2006 Author Share Posted December 17, 2006 alright thanks BillyBoB, I like your way. Link to comment https://forums.phpfreaks.com/topic/30946-solved-if-statements/#findComment-142795 Share on other sites More sharing options...
BillyBoB Posted December 17, 2006 Share Posted December 17, 2006 no problem dude Link to comment https://forums.phpfreaks.com/topic/30946-solved-if-statements/#findComment-142798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.