You are here: Re: Cutting strings short with php « PHP Language « IT news, forums, messages
Re: Cutting strings short with php

Posted by Hello on 07/20/05 07:52

There is a function in PHP that strips the HTML tags called "strip_tags"
then when you get the string back with no tags use "substr" or something to
get the first 100 chars.


"Dave Moore" <dave_m_moore@post2me.freeserve.co.uk> wrote in message
news:dbjluv$chk$1@news5.svr.pol.co.uk...
> Hi All,
> Here's my problem. I have a large textual entry in a database which I
> want to extract and display on a webpage using php. Everything's ok, so
> far.
> However, I only want to show the first 100 characters of the text, not all
> of it. The problem is that the text includes HTML tags. If I simply cut
> the
> text off at 100 characters, there's a chance that I will do so in the
> middle
> of a HTML tag which will then break the rest of the page.
>
> So my question is: can I use php to help me detect an appropriate place to
> cut the string?. Is there a neat function to do this or will I have to
> muck
> around with string analysis functions?. Alternatively is there a way to
> render the whole string but only make the first 100 characters visible?.
> Maybe this would be neater?.
>
> Any comments or suggestions gratefully received.
>
> Ta,
> Dave
>
>
>
>

 

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

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