PHP搜索/过滤文本文件

As the title states, How can I search a text file using PHP and variables. I want to store the user text into a variable and use that as a search parameter in the newplaces.txt file. I know the following code does not work, but hopefully get across what I want to accomplish. I can get a match in the file, but I need help in filtering out the line to only the fields I need

<form method="post" action"http...">
Enter City and State <input name='place' type="text" size="10">
<input type="submit" value="Submit">
</form>
<?php
$f="/newplaces.txt";
$o=file($f);

$a=$_POST['place'];

$c=preg_grep("/\b$a\b/", $o);
echo implode($c, ' ');

$lat=exec("grep -i $a $f | cut -d' '' -f10 ");  //Need help with filtering the match
echo $lat;
?>

Judging from your shell code "grep -i $a $f | cut -d' '' -f10 ", you just want the 10th of the space-separated fields from the matching line. This is easily accomplished via explode, e. g.

$fields = explode(' ', $c[1]);  # $c[1] is the first matching line from the preg_grep()
$lat = $fields[10];             # $fields[10] now is the 10th field from that line
echo "The 10th field is '$lat'.
";