469,950 Members | 1,846 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Lmit Characters

Hi!

I have a MySQL DB with a text field that includes both text and HTML
tags. When I invoke that field in a page, I only see the text (not the
HTML tags, of course). I only want to chow the first 50 characters of
that field, but If use the substr function the result shows my the
HTML tags, because the HTML tags could be in the middle of the substr
limit, I mean:

$text=This is a <B>test</Bthat I want to show

If I use a substr ($text, 18), I receive:

"This is a <B>test<"

I need to avoid the HTML tags and show only the text. I need only to
receive:

"This is a test tha" --18 characters

So...I need only the substring of the result of the field already
formated

Any suggestions?

Thanks!

Ezequiel

Feb 25 '07 #1
1 1199
Hi,

substr(strip_tags($text), 0, 50)

On Feb 25, 5:02 pm, "zek2005" <es*******@gmail.comwrote:
Hi!

I have a MySQL DB with a text field that includes both text and HTML
tags. When I invoke that field in a page, I only see the text (not the
HTML tags, of course). I only want to chow the first 50 characters of
that field, but If use the substr function the result shows my the
HTML tags, because the HTML tags could be in the middle of the substr
limit, I mean:

$text=This is a <B>test</Bthat I want to show

If I use a substr ($text, 18), I receive:

"This is a <B>test<"

I need to avoid the HTML tags and show only the text. I need only to
receive:

"This is a test tha" --18 characters

So...I need only the substring of the result of the field already
formated

Any suggestions?

Thanks!

Ezequiel

Feb 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Roy W. Andersen | last post: by
9 posts views Thread by Safalra | last post: by
43 posts views Thread by Vladimir | last post: by
20 posts views Thread by SMG | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.