help understanding code
Posted: Wed Nov 20, 2002 9:52 am
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.
$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.