You are here: file() and line_num display « PHP Programming Language « IT news, forums, messages
file() and line_num display

Posted by Mark on 03/29/06 05:57

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация