bruno storz wrote:
I have a directory with a bunch of files. Now I want to use a form which
allows me to enter some words which will be used to select files containing
those words.
grep
1. get the words into an array
2. grep foreach word in the files in the directory
3. show results
#v+
<?php
$filespec = '/var/www/htdocs/datadir/*';
// 1
$words = array('word1', 'word2');
// 2
$oneword = '';
foreach ($words as $word) {
$oneword .= `grep -li $word $filespec`;
}
$oneword = explode("\n", $oneword);
$files = array_count_values($oneword);
// 3
foreach ($files as $file+>$dummy) {
echo $file, "<br/>\n";
}
?>
#v-
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--