cgm225 Posted February 18, 2008 Share Posted February 18, 2008 Is there a better way to write this statement to make it shorter? if(($file_extension == "jpg") OR ($file_extension == "JPG")) {} Link to comment https://forums.phpfreaks.com/topic/91789-truncatemake-if-statement-more-efficient/ Share on other sites More sharing options...
kenrbnsn Posted February 18, 2008 Share Posted February 18, 2008 You can use in_array() <?php $exts = array('jpg','JPG'); if (in_array($file_extension,$exts)) echo 'Ok'; ?> or strtolower() <?php if (strtolower($file_extension) == 'jpg') echo 'Ok'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/91789-truncatemake-if-statement-more-efficient/#findComment-470097 Share on other sites More sharing options...
phpSensei Posted February 18, 2008 Share Posted February 18, 2008 try in_array edit: nvm Link to comment https://forums.phpfreaks.com/topic/91789-truncatemake-if-statement-more-efficient/#findComment-470098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.