help understanding code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

help understanding code

Post by penguinboy »

well i'm using this code for a script but i'm not quite sure what it does

$formats = array('jpg','png','bmp');

if(in_array(strtolower(substr($_FILES[img1][name],
-3)),$formats)){ print ("if worked");} else { print("else worked");}


now i'm not quite sure how the if statement works,

basically it says

if(file extension ,$formats)){do this}else{do this}

i've never used a comma in an if statement like that, so i don't know what it does...

the code i took this from was a file uploading script

but the way they had it was

anything in $formats was not allowed to be uploaded, but for some reason my code only lets me upload what is in $formats
but thats what i want, I just want to understand why its doing that.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

never mind, another guy helped me in phpbuilder's forums
Post Reply