954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

serch text file

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['path'];

$jaar=$_POST['years'];
$num= $_POST['name'];
echo $court."
";
$mn=$_POST['mnumber'];
echo $mnc."
";
$toSearch = "[".$jaar."]"." ".$name." ".$mn;
echo $toSearch."
";

$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."
";

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

$count=$lineNumber;
echo $lineNumber."
";
write($lineNumbers,$lineNumber);

}

}

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

//echo $str_array[0]."
";

}

else

{

$line="no file/folder found";

echo $line;

}

cosby
Newbie Poster
14 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

i dont know deeply..
use array_search();

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 
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

cosby
Newbie Poster
14 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You