You are here: Re: extract a part of string from other string « All PHP « IT news, forums, messages
Re: extract a part of string from other string

Posted by BoneIdol on 11/16/07 11:10

On 14 Nov, 19:16, Tom <t...@to.com> wrote:
> On Tue, 13 Nov 2007 16:34:18 +0100, artev wrote...
>
> >I would like to extract a piece of string inner oneother;
> >how rule for extraction all text inner this ">.......</a>
>
> >example if I have this string
> ><li><a href="http://localhost/namesitos/index.php?pg=id=b8f">Title &amp;
> >Test</a></li>
>
> >the code will return Title &amp; Test
>
> You can use preg_replace() similar to this...
>
> <?php
>
> $string = '<li><a href="http://localhost/namesitos/index.php?pg=id=b8f">Title
> &amp; Test</a></li>' ;
>
> echo preg_replace('/<li><a href\=.+>(.+)<\/a>\<\/li>/', "$1", $string);
>
> ?>
>
> Tom
> --
> NewsGuy Free Trial Accounts
> Now a massive 20 Gigabytes of unrestricted downloads !http://newsguy.com/

If you're just wanting to strip all the html from input (and I mean
strip, not escape with entities) just use strip_tags(). I haven't used
it in a long time, but I seem to recall that it would leave the text
between tags unmolestred.

http://www.php.net/strip-tags

 

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

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