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.

$q=$_POST;


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


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


$lines = file($file);


$count;
$lineNumbers;


if ($lines)


{


foreach($lines as $lineNumber)


{
$lineNumbers++;


$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];


$count=$lineNumber;
echo $lineNumber."<br />";
write($lineNumbers,$lineNumber);


}


}


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


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


}


else


{


$line="no file/folder found";


echo $line;


}

Recommended Answers

All 2 Replies

i dont know deeply..
use array_search();

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.