You are here: Re: remove all lines starting with b « PHP Programming Language « IT news, forums, messages
Re: remove all lines starting with b

Posted by d on 11/18/13 11:43

"Rex" <eric.fiori@gmail.com> wrote in message
news:1143445129.437173.181710@t31g2000cwb.googlegroups.com...
>I believe you want to read the file line by line and then try and match
> your regex to each line. try:
>
> $handle = @fopen("dummy.txt", "r");
> if ($handle) {
> while (!feof($handle)) {
> $buffer = fgets($handle);
> if( !preg_match('/^b.*?\n/',$buffer) )
> echo $buffer . "<br>";
> }
> fclose($handle);
> }

You could use substr($buffer, 0, 1)=="b" as opposed to preg_match, as
preg_match is a bit more intensive than just substr...

 

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

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