hi everyone i am new in php and i want to serch the specific words on text file using pregmach .
i have try the patterns of the pregmatch() but it seems like i dont doit right.
can someone look into my code and help me out with this problem.


$num= $_POST;
echo $court."<br />";
echo $mnc."<br />";
$toSearch = "[".$jaar."]"." ".$name." ".$mn;
echo $toSearch."<br />";

$file =$q."file1.txt";

$lines = file($file);


if ($lines)


foreach($lines as $lineNumber)


$foundAMatch = preg_match("/[A-Za-z_0-9]$toSearch\b/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);

if ($foundAMatch > 0)

echo $foundAMatch."<br />";

$found = $matches[0][0];

echo $lineNumber."<br />";



//$str_array = explode(" ",$count);

//echo $str_array[0]."<br/>";




$line="no file/folder found";

echo $line;


Edited 3 Years Ago by happygeek: fixed formatting

i dont know deeply..
use array_search();

it dosent work i have try it before,sorry i didi'nt gve you the structure of my file.

"2005_32.rtf" (23 ) S v Manqaba [2005] simon 45 ;
"2005_33.rtf" (24) Simon v Manqaba [2005] Dan 46 ;

basically i want to search this [2005] name number

This article has been dead for over six months. Start a new discussion instead.