All right, so I have this script that is searching a listing of a filenames from a directory for anything containing mp3 and tif.
The preg_match for "mp3" ($extMatchMp3 = preg_match("/mp3/i", $file)😉 works just fine.
The preg_match for "tif," which uses the exact same format ($extMatchTif = preg_match("/tif/i", $file)😉 will not identify the tif file in the folder as a tif. It identifies the mp3 file and echoes the proper link.
The link for the tif is incorrect (because the matching is not working properly.
I echo the result for each match and it comes out as:
1 AND 0sbtechno.mp3 - match1
0 AND 1Ducky.tif - match1
In the output, the first number in the "1 AND 0" is the search for mp3 and the 0 is the search for "tif."
I even changed the search for "tif" to just "t" and got this:
1 AND 1sbtechno.mp3 - match1
0 AND 1Ducky.tif - match1
The "x AND y" part is echoed in front of the filename for testing purposes. The match 1 is also for testing.
Below is the code that lists the files during a while loop:
if (($file != ".") && ($file != "..") && ($file != ".DS_Store")) {
echo $extMatchMp3." AND ".$extMatchTif;
if ($extMatchMp3 == "1") {
$path2 = "$path/$file";
echo "<a href=\"download.php?path=$path2\">$file</a> - match1 $extMatch1<br>";
} elseif ($extMatchMp3 == "0") {
$path2 = "$path/$file";
echo "<a href=\"index.php?path=$path2\">$file</a> - match1 $extMatch1<br>";
} elseif ($extMatchTif == "1") {
$path2 = "$path/$file";
echo "<a href=\"download.php?path=$path2\">$file</a> - match1 $extMatch1<br>";
} elseif ($extMatchTif == "0") {
$path2 = "$path/$file";
echo "<a href=\"index.php?path=$path2\">$file</a> - match1 $extMatch1<br>";
}
}
Any and all help is appreciated. I'm stumped.