You are here: Re: Read a file with filter, and give the output « PHP Programming Language « IT news, forums, messages
Re: Read a file with filter, and give the output

Posted by burgermeister01@gmail.com on 08/27/07 14:42

On Aug 27, 8:31 am, innamorato.pa...@gmail.com wrote:
> Hi!
> I would like to create a php script that read a txt file and filter it
> with 2 keywords, first keyword deifne the start and the second one the
> end of the txt to read.
> And then give the output extracted.
>
> Expter of the group, could you help me?
> thanks!

You might be looking for something like the following. I haven't
tested this, so I'm sure my string parsing is off by one, or
something. Also the variable names are kind of long for clarity's
sake; you may want to shorten them.

$file_path = "/path/to/file.txt";
$contents = file_get_contents($file_path);

$start_string_position = strpos($contents, "start");
$end_string_position = strpos($contents, "end",
$start_string_position);
$extracted_string_length = $end_string_position -
$start_string_position;

$extracted_string = substr($contents, $start_string_position,
$extracted_string_length);

 

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

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