I have a script that search's for the word in the file just fine, I would like to echo the line number it was found on.
Thank you.
<html>
<body>
<form name="form" method="post">
input: <input type="text" id="search" name="search_box" style="background:#000006; color: #FF0000" />
</p>
</p><input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
$path = 'users.txt';
$input = $_POST['search_box'];
$cookie_file_path=$path;
$minimum_length = 2;
if(isset($_POST['submit'])){
if (!strlen(trim($_POST['search_box']))){
echo "You must enter an input.";
} else {
if (strlen($_POST['search_box']) < $minimum_length) {
echo 'The input is too short; minimum length is 2 characters.';
}
else{
$file = file_get_contents($path);
$SearchString = $input;
$breakstrings = explode('/',$SearchString);
foreach ($breakstrings as $values)
{
if(!strpos($file, $values))
{
echo $values." is NOT found\n";
}
else{
echo $values." was found\n";
} }
}
}
}
?>