You are here: Re: Reading a file and extracting data (using regular expressions maybe?) « All PHP « IT news, forums, messages
Re: Reading a file and extracting data (using regular expressions maybe?)

Posted by Tyrone Slothrop on 02/01/06 03:56

On 31 Jan 2006 15:27:22 -0800, "Redfox05" <redfox05@gmail.com> wrote:

>Hi,
>im not sure how this is going to work but this is the aim:
>
>I need to figure out how to be able to read a file and scan it for
>certain phrases and then extract the information at a certain point.
>
>To be more specific, I want to read a file generated by webalizer, and
>extract the bit where it states the total monthly bandwidth, so I can
>display this on a site without showing all the other more detailed
>stats stuff.
>
>Is this possible? Or is my idea just way to far into fantasy world.
>But just incase it is possible, am I doing the right thing, would there
>be a way which is a lot more easier.
>
>Thanks in advance.

Nothing much to it. Use the file() function and look for your
matches. Of course, the file must have the proper permissions to be
read by PHP.

$lines = file("/path/to/report");
foreach ($lines as $line) {
if (strstr ($match, $line) {
echo $line;
}
}

 

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

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