You are here: Re: take text from a string « PHP Language « IT news, forums, messages
Re: take text from a string

Posted by Thomas Mlynarczyk on 11/13/07 15:49

Also sprach artev:

> 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


To get just the text inside an <a> element, you can try something like this
(untested):

preg_match( '°\<a\s+[^>]+\>(.*?)\</a\>°', $text, $matches )

$matches[1] will then contain the text.

But if you want to remove all HTML, have a look at PHP's strip_tags()
function.

Greetings,
Thomas

--
C'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)

 

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

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