Reply to Re: Match a filename from a text file

Your name:

Reply:


Posted by robert on 10/10/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?

[Back to original 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

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