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

Posted by Dave Moore on 07/19/05 22:46

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

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