PHP Code Help Please
Posted: Tue Dec 23, 2003 9:20 pm
Hello -
I'm trying to open a flat text data file. In it I have a list of image files names & words (example test1.jpg, test, test2.jpg, ect). I want to detect which is which and then have a action happen. This is what I have so far -
<?php
$TheFile = "data3.txt";
$Open = fopen ($TheFile, "r");
if ($Open) {
print ("URLs currently listed in the data file:<P>\n");
$Data = file ($TheFile);
for ($n = 0; $n < count($Data); $n++) {
$GetLine = explode("\t", $Data[$n]);
print ("$GetLine[0]<BR>\n$GetLine[1]<P>\n");
}
fclose ($Open);
print ("<HR><P>\n");
}
$filename = "$GetLine";
$extention = GetFileExtention($filename);
echo $extention;
//
function GetFileExtention($filename) {
$ext = explode(".", $filename);
$extention = "";
for($i=1;$i<=sizeof($ext)-1;$i++) {
if($ext) {
$extention .= ".".$ext[$i];
}
}
return $extention;
}
?>
I'm trying to open a flat text data file. In it I have a list of image files names & words (example test1.jpg, test, test2.jpg, ect). I want to detect which is which and then have a action happen. This is what I have so far -
<?php
$TheFile = "data3.txt";
$Open = fopen ($TheFile, "r");
if ($Open) {
print ("URLs currently listed in the data file:<P>\n");
$Data = file ($TheFile);
for ($n = 0; $n < count($Data); $n++) {
$GetLine = explode("\t", $Data[$n]);
print ("$GetLine[0]<BR>\n$GetLine[1]<P>\n");
}
fclose ($Open);
print ("<HR><P>\n");
}
$filename = "$GetLine";
$extention = GetFileExtention($filename);
echo $extention;
//
function GetFileExtention($filename) {
$ext = explode(".", $filename);
$extention = "";
for($i=1;$i<=sizeof($ext)-1;$i++) {
if($ext) {
$extention .= ".".$ext[$i];
}
}
return $extention;
}
?>