Re: [PHP] Re: Search a flat file.

2002-06-08 Thread Miguel Cruz
If the file is of a reasonable size (not hundreds of kilobytes), then you can just slurp it all into an array and foreach through it: $matched = 0; $myfile = file('/usr/home/crud/myfile'); foreach ($myfile as $line) { $split_line = explode(':', $line); if ($split_line[1] ==

[PHP] Re: Search a flat file.

2002-06-08 Thread Daniel Grace
Be warned that explode won't work as expected if any of your fields contain colons, though it doesn't look like it'll be an issue in this sort of case. Gaylen Fraley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Use the explode() function based on the colon.

[PHP] Re: Search a flat file.

2002-06-07 Thread Gaylen Fraley
Use the explode() function based on the colon. Then parse the 2nd array element for the username that you want. If matched, display all elements in that array row. Conversely you could use the implode() to reassemble the array row. (Assume $file_row is the row name that you have assigned) /*

Re: [PHP] Re: Search a flat file.

2002-06-07 Thread Tom Ray
ok I believe I follow you on that, I will give that a try. But the question I have now is how do I loop that request? Gaylen Fraley wrote: Use the explode() function based on the colon. Then parse the 2nd array element for the username that you want. If matched, display all elements in that