OK, I have been racking my brains for a day now, and am succumbing to stupidity...
I have a text file that I want to search for a specific word, and I am not getting it....
Samle Text File
John 100 200 300 400
Dave 200 300 400 100
Mike 599 399 399 299
Jimmy 500 300 400 400
What I want to do is search the file for the name "Dave" and extract the data just from the line with Dave. I am going to load the values into an array and manipulate that within PHP. Now, the trick is, I have an array...
array("Dave", "Sarah", "Sam", "Jimmy");
I want to cycle through the array, and pull all of the lines that match my values in the array, so with the above array, I would get the lines:
Dave 200 300 400 100
Jimmy 500 300 400 400
I have tried using:
$cid = explode(",", $names);
$countnames = count($cid);
$lines = file("./swr/".$sid.".txt");
FOREACH ($lines as $line_num => $line):
// This is the part I am stuck with. I don't know how to search each line to match the $cid[] array. I have tried using a FOR loop, but that hasn't worked.
ENFOREACH;
Any help would be appreciated. If you need more info, just ask.
Thanks in advance,
TheDefender