Hello all,
I have the following file.txt storing these kind of values:
Name: John Doe
E-mail: jo**@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: bi*******@owns. microsoft.com
Phone: (222) 345-6667
Address: P.O. Box 36 (73456) OK - Leedey USA
Member ID: 517805250943762 6
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: 517805250943762 6 E-mail: bi*******@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($userf ile);
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