Let's say you have this in foo.txt
aaa|bbb|ccc
ddd|eee|fff
ggg|hhh|iii
Then this is a function I made for you
function SearchInFile($strNeedle,$strFile)
{
$file = file($strFile);
for($i = 0; $i < count($file); $i++)
{
$parts = explode('|',$file[$i]);
if(in_array($strNeedle,$parts))
{
return $parts[0] . ', ' . $parts[1] . ' and ' . $parts[2];
}
}
}
How you use this function:
echo SearchInFile('ggg','foo.txt');
Output should be:
ggg, hhh and iii