The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Special Forums > Web Programming, Web 2.0 and Mashups
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-20-2009
timgolding timgolding is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 34
How much have you done. Have you got any of this in place? You can search for the numbers and display the line easily enough with preg_match

PHP Code:
$numbers_to_search '123400 0000001';
$file_to_search 'path_to_file';

$numbers_to_search str_replace(" ""\s"$numbers_to_search);
$str=$file_get_contents($file_to_search);
if(
preg_match_all("/(\r\n|\n|\r).*".$str.".*(\r\n|\n|\r|$)/u"$str$matches))
{
     
print_r($matches);

Is it always going to be number though. or could it be any text to search. If it could be any text then using a regex might not be so useful. Maybe using the file command would be better

Last edited by timgolding; 05-20-2009 at 07:42 AM..