473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1298
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
47792
by: Pikkel | last post by:
i'm looking for a way to replace special characters with characters without accents, cedilles, etc.
7
8944
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create zip-files without needing the zip-file extension in PHP,...
9
8132
by: Safalra | last post by:
The idea here is relatively simple: a java program (I'm using JDK1.4 if that makes a difference) that loads an HTML file, removes invalid characters (or replaces them in the case of common ones...
43
3677
by: Vladimir | last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2. Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4. But why that? Look: /* Each Unicode character...
4
3821
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
20
9329
by: SMG | last post by:
Hi All, I have created an application which is working fine and is in about to launch, now suddenly my mgmt says there are chances that Scrip ID( a particular id and not prim key) may have special...
11
11086
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
9
3911
by: Nathan Sokalski | last post by:
I have several TextBoxes with TextMode="MultiLine" in which I want to limit the number of characters that can be entered using a RegularExpressionValidator. I have come up with the following...
3
10172
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.