Hello I'm having issue with php in_array function. I want to check the uploaded files extension whether it meets my requirement or not, and for that I'm using following code.
$imgExtension = explode(".",$imageName);
$allowed_extension = array("png","jpg","jpeg","gif");
echo $end = end($imgExtension);
if(in_array(trim($end),$allowed_extension)){
echo "File is correct";
}else{
echo "File is incorrect";
}
The issue that I'm facing is the in_array function, the uploaded file's extension is jpg,png and jpeg, yet the in_array condition turns false, don't know why...
but instead of $end variable, if I pass any string like "jpg" or "png" in in_array functions parameter, then it works...