You are here: Re: Match a filename from a text file « All PHP « IT news, forums, messages
Re: Match a filename from a text file

Posted by Juby on 09/28/27 11:46

Well, that's the weird thing, I've also been having it spit out the
full path, and if I copy and paste the line in the browser to the 'Run'
box, the file opens, no problem. As for the parsing bit, here's what I
have right now (I'm using preg_match, but I've also tried using
explode, neither is working):

$path = "C:\\Users\\AAAHelp\\Variable Identity\\AAA Menu Label [Math
Type]\\";
$directory = dir($path);
$file = file("variables.txt");

$count = count($file);
$foo = TRUE;

function utrim($source){
$temp = ltrim($source);
$temp = rtrim($temp);
$temp = trim($temp);

return $temp;
}

for($i=0;$i<$count;$i++){
$filename = $file[$i];
preg_match("/^\ .+?\ /", $filename, $matches);
$filename = utrim($matches[0]) . ".wmf";
$filename = $path . $filename;

$thisFile = file_exists($filename);
if($thisfile == FALSE){
echo "$filename does not exist.<br />\n";
$foo = FALSE;
}
}


if(file_exists($path . "OpACoeffofPowervsSpeed.wmf")){
echo "Test file okay.<br />\n";
} else {
echo "Test file gone.<br />\n";
}

if($foo){
echo "All variable files present and accounted for.";
}

When run, this script will print out that none of the files exist
(which is false), but then the second test, if(file_exists($path .
"OpACoeffofPowervsSpeed.wmf")), will print out "Test file okay."

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация