Parsing text files

General discussions related to php

Moderators: macek, egami, gesf

glow
New php-forum User
New php-forum User
Posts: 10
Joined: Tue Nov 26, 2002 11:00 am

Parsing text files

Postby glow » Mon Dec 16, 2002 3:51 am

Hi all i've a generall question about parsing text files.

What's the simplest way for searching, for example e-mail adresses, in a text file? is there already a php function for something like this available? (excuses my bad English)

THX ahead for your answers :wink:

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Dec 16, 2002 4:36 am

simple serch code


Code: Select all

$file=file("file.txt");

$num=count($file);
for ($i=0; $i < $num; $i++)
{
    if (eregi("[a-z]+@[a-z]+\.[a-z]{2,3}", $file))
    {
    echo  " $file[$i]\n<br>";
    }
}

glow
New php-forum User
New php-forum User
Posts: 10
Joined: Tue Nov 26, 2002 11:00 am

THX

Postby glow » Mon Dec 16, 2002 4:58 am

great! Thanks a lot! :-)

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Dec 16, 2002 5:02 am

you wellcome! =)


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron