I am having some difficulty getting a single line from a text file. I can do that using grep in UNIX but having problems in php. I tried preg_grep and getting nothing. Here is what I have so far.
the php file is called getText.asp and is called from another webpage sending the value to search for, for example, getText.asp?id=10774
What am I doing wrong?
TIA
Mike
the php file is called getText.asp and is called from another webpage sending the value to search for, for example, getText.asp?id=10774
Code:
$id = $_GET['id'];
$path = "/path/to/file";
$filename = "nameoffile";
if (isset($id)){
$lines = file($path . $filename);
foreach($lines as $line){
$item = preg_grep($id, $line);
if($item != ""){
echo $item;
exit;
}
}
}
What am I doing wrong?
TIA
Mike