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 Geoff Berrow on 10/04/45 11:43

Message-ID: <4427b828$0$11073$e4fe514c@news.xs4all.nl> from Erwin Moller
contained the following:

>Read this:
>http://nl3.php.net/manual/en/reference.pcre.pattern.modifiers.php
>
>So you could add the m modifier, like this:
>echo preg_replace('/^b.*\\n/m','',$contents);
>
>where:
>^b means begins with b
>.* means: anything untill end of line (\n) is reached
>\\n means the end of line
>and the m outside the // means that your string is treated the way you ment
>too (see description at www.php.net).

I really have to learn more about regex. In the meantime...

<?
$contents = file('dummy.txt');
foreach($contents as $value){
echo ($value{0}!="b")? $value."<br>" : "";
}
?>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

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

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