|
Posted by Jerry Stuckle on 03/29/06 06:34
Mark wrote:
> Hello all,
>
> I have the following file.txt storing these kind of values:
>
> Name: John Doe
> E-mail: john@doe.com
> Phone: 555 865 8901
> Address: 71 Huntington Ln. (33444) FL - Delray Beach US
> Member ID: 373732510149005
> Registration date: 5/2005
> Access code: 6691
> Comments: Thanks, great community
> ============================================
> Name: Bill Gates
> E-mail: billgates@owns.microsoft.com
> Phone: (222) 345-6667
> Address: P.O. Box 36 (73456) OK - Leedey USA
> Member ID: 5178052509437626
> Registration date: 10/2005
> Access Code: 969
> Comments: Reffered by Josh Portua. Give him credit
> ============================================
> Name: ...... and so on
>
> I want to search the file.txt after 3 predefined Member ID prefixes:
> $prefix1="51780";
> $prefix2="37373";
> $prefix3="72215";
> show the Member IDs that match this rule and also display for the found
> matching Member IDs their E-mail and Name.
>
> So the search on the part of file.txt shown at the start will result:
> Member ID: 5178052509437626 E-mail: billgates@owns.microsoft.com Name:
> Bill Gates
>
> I have built something like this so far:
>
> <?php
> $prefix1="51780";
> $prefix2="37373";
> $prefix3="72215";
> $userfile = "users.txt";
> $fc=file($userfile);
> foreach($fc as $line_num => $line)
> {
> if (strstr($line,$prefix1))
> echo "Found one match at {$line_num} $line<br>";
> if (strstr($line,$prefix2))
> echo "Found one match at {$line_num} $line<br>";
> if (strstr($line,$prefix3))
> echo "Found one match at {$line_num} $line<br>";
> }
> ?>
>
> What I can't do is showing the emails and names for the found member
> ids. Please, can you give me any suggestions? I'm completly blank.
>
> Thank you for your time.
>
> Regards,
> Mark
>
Mark,
I'd use a database such as MySql or Postgres. They are ideally suited for this
kind of operation. And it's not that hard to program for them.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|