|
Posted by robert on 09/28/65 11:46
here's how i tested it. i optimized your use of preg. it is more effiecient
to call it once over large strings than multiple times over smaller ones.
assuming each line of the file contains this format: label = 'value';
ex. OpACoeffofPowervsSpeed = 'OpACoeffofPowervsSpeed';
<?
$path = 'C:/Users/AAAHelp/Variable Identity/AAA Menu Label [Math Type]/';
// next line assumes php 5...otherwise read the file in as a string, not an
array
$files = @file_get_contents('variables.txt');
// following line is for my testing purposes
// "blah, blah, blah" is just noise for the preg to screen out
$files = "
blah, blah, blah, OpACoeffofPowervsSpeed =
'OpACoeffofPowervsSpeed'; blah, blah, blah
blah, blah, blahOpAPowervsSpeed = 'OpAPowervsSpeed'; blah, blah,
blah
blah, blah, blahOpACoeffofSpeed = 'OpACoeffofSpeed'; blah, blah,
blah
";
// comment out the above to test with your actual variables.txt file
preg_match_all("/\s[^']+'([^']+)'\s*?;/si", $files, $fileNames);
$fileNames = $fileNames[1];
foreach ($fileNames as $fileName)
{
$fileName .= '.wmf';
$message = file_exists($path . $fileName) ? 'GOOD' : 'BAD';
echo '<pre>' . $message . ' == ' . $path . $fileName . '</pre>';
}
?>
does that help?
Navigation:
[Reply to this message]
|