<html>
<head>
<title>Week #11 Example ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>
<? // [ PATHS ]
$fContents = file("basic/email.txt" , "r");
$sizeof = count($fContents);
?>
<?php
// [ MATCH FILES ]
// Must have the \n for in_array() if
// there are returns in the file being read
if($_POST['action'] == "match_all"){ // Button press
$arrToMatch = $_POST['toMatch']; // Array of Entered Items
foreach($arrToMatch as $entry){
if($entry){
foreach($fContents as $line){
if(eregi($entry,$line)){
print("Found <i>$line</i><br>");
$matched++;
}
}
}
}if($matched){
print("Total Matches: <i>$matched</i>");
}
}
?>
<table border="1">
<tr>
<td valign="top">
<?php // [ MATCH FORM ] ?>
<form method=POST action="<? echo($PHP_SELF); ?>" style="margin:0;">
<input type="hidden" name="action" value="match_all">
<?
$number_of_inputs = 3;
print('<p><b>Entry(s) to Match:</b><br>');
for($i=0; $i<$number_of_inputs; $i++) {
print("<input type=text name=toMatch[] size=15><br>"); // Input box
}
?>
<input type="submit" value="Find Matches">
</form>
</td>
<td valign="top"> <b>File Entries:</b><br>
<?php // [ SHOW USERS ]
$fContents = file("basic/email.txt");
$sizeof = count($fContents);
for($i=0; $i < $sizeof; $i++) {
print("$fContents[$i]<br>");
}
?>
</td>
<td valign="top">
<? // [ DEBUG ] ?>
$sizeof = <? print_r($sizeof); ?><br><br>
$action = <? print_r($action); ?><br><br>
$fContents = <? print_r($fContents); ?><br><br>
$arrToMatch = <? print_r($arrToMatch); ?><br><br>
$toMatch = <? print_r($toMatch); ?><br><br>
$flag = <? print_r($flag); ?><br><br>
<? var_dump($_POST); ?><br><br>
</td>
</tr>
</table>
<pre>
</pre>
<a href='../index.html'>Index</a>
<br>
<iframe src='examplesrc.php' width='100%' height='300'></iframe>
<br>
<a href='../index.html'>Index</a>
</body>
</html>