Connecting Tech Pros Worldwide Help | Site Map

Lmit Characters

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 25th, 2007, 09:15 PM
zek2005
Guest
 
Posts: n/a
Default 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


  #2  
Old February 25th, 2007, 09:25 PM
petersprc
Guest
 
Posts: n/a
Default Re: Lmit Characters

Hi,

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

On Feb 25, 5:02 pm, "zek2005" <esapoznik@gmail.comwrote:
Quote:
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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.