I have a script that lists directories..now I needed for the script to link to another page when a certain type of file has an extension that is listed. Right now its echoing the argument whether or not the file with the extension is there... can someone look at this and see the mistake? $ext = array_pop(explode(".", $file)); if (strpos("|m4a|mp3|jpg|jpeg|wav|jar|jad|qcp", $ext)) $filezz = $ext; echo "<td> <span style=\"text-transform: uppercase\"><a href=\"?page=filter&location=$starto§ion=$startp\">Click Here To Proceed</font></a> </td>\n"; die; PHP: Thanks for the help!
strpos() doesn't take patterns like that. Use preg_match() instead: if (preg_match("~m4a|mp3|jpg|jpeg|wav|jar|jad|qcp~i", $ext)) PHP:
You could also put all of those extensions in an array, and use in_array(). A little lighter than preg_match, but not a huge difference. $valid = array('m4a','mp3','jpg','jpeg','wav','jar','jad','qcp'); if(in_array($ext,$valid)) { //everythigs OK } PHP:
Try this one!!!!! echo "<td> <span style='text-transform: uppercase'><a href='?page=filter&location=$starto§ion=$startp'>Click Here To Proceed</font></a> </td>\n";