extract a part of string from other string

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 &
Test</a></li>

the code will return Title & Test
artev [ Di, 13 November 2007 16:34 ] [ ID #1869511 ]

Re: extract a part of string from other string

Post removed (X-No-Archive: yes)
Notifier Deamon [ Mi, 14 November 2007 20:16 ] [ ID #1870522 ]

Re: extract a part of string from other string

On 14 Nov, 19:16, Tom <t... [at] 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 &
> >Test</a></li>
>
> >the code will return Title & Test
>
> You can use preg_replace() similar to this...
>
> <?php
>
> $string = '<li><a href="http://localhost/namesitos/index.php?pg=id=b8f">Title
> & 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
BoneIdol [ Fr, 16 November 2007 12:10 ] [ ID #1872593 ]
PHP » alt.php » extract a part of string from other string

Vorheriges Thema: Does anyone use Glob?
Nächstes Thema: PHP Developers Required