You are here: Re: Trimming Text « PHP « IT news, forums, messages
Re: Trimming Text

Posted by Al on 10/07/62 11:21

André Medeiros wrote:
> Greetings.
>
> I am trying to trim some text containing HTML tags. What I want to do is
> to trim the text without trimming the tags or html entities like  
> and such, wich completelly break the design.
>
> Has anyone succeded on doing such a thing? phpclasses.org won't help :(
>
> Thanks in advance.
> André

Consider...

Making a preg pattern to capture everything between tags and then use preg_replace_callback()
process the "captured text" with the called function.

It will work; but it's a bit tricky.

Here is a similiar code snip to get you started...

$pattern= "%<[\w-/]+>%";

$text= preg_replace_callback($pattern, create_function('$matches', 'return
strtolower($matches[0]);'), $text);

This converts all tags to lowercase.

You probably should use a regular callback function rather than creating one.

 

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

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