Need to find an exact match from within a .txt or .htm file and there could be an empty space before any given number.
The code I tested below finds it, but not an exact match; what am I doing wrong?
<?php
$filename = 'if3.txt';
//$searchfor = '/^123456$/';
fopen($filename);
// $searchfor = "/\b123456/\b";
// $searchfor = '/\b123456\b/i';
$searchfor = '/^123/';
$file = file_get_contents($filename);
// if(strstr("\b$file\b", $searchfor))
if(stristr($file, $searchfor))
//if(preg_match("\b$file\b", "$searchfor"))
{
echo "String found";
}
else
{
echo "Nope";
}
fclose($filename);
?>