it dose't serch.maybe my serching pattern is not right.look at the following code.
Myfile look like this
--------------------------------
file : (49/06/01) [2007] simon 13;
file : (68/05/01) [2007] John 17 ;
i want to serch [2007] simon 13 on the text file.
can anyone help me with pregmatch patterns.
Expand|Select|Wrap|Line Numbers
- <?php
- $jaar = $_POST[year];
- $name = $_POST[name];
- $empno = $_POST[employeeno];
- $file =$q."Myfile.txt"; // q =path to myfile
- $toSearch = "[".$jaar."]"." ".$name." ".$empno;
- $lines = file($file);
- $count;
- $lineNumbers;
- if ($lines)
- {
- foreach($lines as $lineNumber)
- {
- $lineNumbers++;
- $foundAMatch = preg_match("/$toSearch/i", $lineNumber, $matches, PREG_OFFSET_CAPTURE);
- if ($foundAMatch > 0)
- {
- $found = $matches[0][0];
- $count=$lineNumber;
- echo $lineNumber."<br />";
- }
- }
- //$str_array = explode(" ",$count);
- //echo $str_array[0]."<br/>";
- }
- else
- {
- $line="no file/folder found";
- echo $line;
- }
- ?>