i need to write a script to find the number occurances of given substring in file.
the form should consists of a drop down menu for choosing a particular string.selecting the particular string and pressing the submitt button should give the number of occurances of the substring in the given file. for that i created a function and passed the 3strings in an array.
function project () { //start of the function
$strings = array ( 1 => 'string1', 'string2,', 'string3' );
print '<select name="select a string">';
foreach ($strings as $key => $value) {
print "\n<option value =\"$key\">$value</option>";
}
print '</select>';
} //end of the funtion
the second part of the code is the reading the file and counting the number of occurances of the substring within the file.....
project();
print '<form action="view_quote.php" method="post">
<input type="submit" name="submit" value="No of Occurances!" />
<br />
</form>';
$data = file('../public_html/har.txt');
$n = substr_count($data, "srtring1");
?>
</body>
</html>
what i need to get is i need to select each string and after pressing the submit button i need to get the number of occurances of the string in file printed.