Jump to content

Recommended Posts

$text = "$description"; echo ShortenString($text);
function ShortenString($text)
{
// Number of characters you want to display
$num_chars = 100;
$text = $text." ";
$text = substr($text,0,$num_chars);
$text = substr($text,0,strrpos($text,' '));
$text = $text."...";
return $text;
}
?>
$text = "$description";
echo ShortenString($text);
function ShortenString($text)
{
// Number of characters you want to display
$num_chars = 100;
$text = $text." ";
$text = substr($text,0,$num_chars);
$text = substr($text,0,strrpos($text,' '));
$text = $text."...";
return $text;
}
?> 
$num_chars = 100; // change to number of charecters.
$text = "$description"; text = database varable.
I have another problem using substr() my description field is stored in database and is non english language. I used html editor to store the values. When I type any Character in the editor and dont use formatings from html editor, the values displayed corectly. But when I do Formating and apply these settings, nothing is shown.  this means, when I use substr function, it has some confliction with the html stored in the database. here is an example. field name is description and the value from database is as follows

[color=red]This value I copied Paste and used HTML Editor to increase / decrease size etc [/color]


$description = <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt; DIRECTION: rtl; unicode-bidi: embed; TEXT-ALIGN: justify"><SPAN lang=AR-AE style="FONT-SIZE: 14pt; FONT-FAMILY: 'Simplified Arabic'; mso-bidi-language: AR-AE">ÊÎÊÕ ÅÏÇÑÉ ÇäÈÍèË èÇäÇÓÊÔÇÑÇʬ ÇäÊê ÊÙÏ åæ ÇäÅÏÇÑÇÊ ÇäÑÆêÓêÉ ÈÇäåÙçϬ ÈÇäÅÔÑÇá èÇäÊèÌêç èÇäÊæÓêâ Èêæ ÇäÃæÔ×É ÇäåÎÊäáÉ ÇäåÑÊÈ×É ÈåÌÇäÇÊ ÇäÈÍèË èÇäÇÓÊÔÇÑÇÊ èÇäåãÊÈÇÊ èÇäèËÇÆâ èÇäæÔÑ</SPAN><SPAN lang=AR-SA style="FONT-SIZE: 14pt; FONT-FAMILY: 'Simplified Arabic'">.èÊäÙÈ ÇäÅÏÇÑÉ ÏèÑÇ åÍèÑêÇ áê ÊÍâêâ ÇäåÙçÏ äÃçÏÇáç èÊæáêÐ ÇäåçÇå ÇäÊê Ãæê×Ê Èç áê åÌÇä ÇäÇÑÊâÇÁ ÈåÓÊèé ÇäÅÏÇÑÉ ÇäÍãèåêÉ èÊÈÓê× ÅÌÑÇÁÇÊ ÇäÙåä ¬ è ÇäåÓÇçåÉ ÇäáÙÇäÉ áê ÇäÊæØêå ÇäÅÏÇÑê&nbsp; åæ ÎäÇä ÅÙÏÇÏ ÇäçêÇãä ÇäÊæØêåêÉ èÊâÏêå ÇäÇÓÊÔÇÑÇÊ ÇäÅÏÇÑêÉ èÅÌÑÇÁ ÇäÈÍèË èèÖÙ ÇäÍäèä ÇäåäÇÆåÉ ääåÔãäÇÊ ÇäÊê ÊÙèâ ÇäÙåä áê ÇäÃÌçÒÉ ÇäÍãèåêÉ ÇäÇÊÍÇÏêÉ èÇäåÍäêÉ .</SPAN><SPAN dir=ltr style="FONT-SIZE: 14pt; mso-bidi-font-family: 'Simplified Arabic'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>

These Values dont show any thing in the Page.

Here is another record in whcih I didn't use any HTML editor functionalities. Just type the values and clicked submit. Here is how it looks.

$description = <P>æåÊåæÊæå&nbsp; ÇÊæÇ æÊÇæ ÊÇæ ÇçÙ Ç ÇÙç ÇÚÙç ÚçÙ Ú Ù ÈÑäÇ ÑÊÇ äÇÊæ äÇçÊ Çä ÙÚä ÙÚ ÊÇääÇÙçä Ùç äÙç ÇÙç ÇÊ äÇÑ ÇÊääÇ&nbsp; äÊæÇ Ùç ÇÙç ÇÙç ÇÙç ä Úä ÙáÚÈÑ áÚÈÄ ÚÑ&nbsp; ÑÇÊäÇ ÊäÇ ÊÇäÇ&nbsp; äÑÚÙ äÙÚ äÙÚ È áÚÙ Êæ æÊ æ ÊÇ ÊÇÑ äÇÑ Ù ÑÙ ÑÙÚ ÑÙÚ Ñ ÙÚ ÙÚäÇ ÙäÇ ÙÚ äÇÙ äÇ ÙÚäÇ ÙÚäÇÑ ÙÚ ÈÑÚ ÄáâÄ áâ Äá ä Ñ ÊÇ ÊÇ ÊÇ äÇ ÇäÇ ÙÚ äÚÙ äÙÚ äÙÚ äÙÚ ä ÚÙä ÙÚä È âáÈê â êâêâê â êâ êËâ&nbsp; È ÄÈ ÄÈ Ä ä ÑÄä ÑäÇ Ñ äÇÑ äÄ&nbsp; áÄ âê â â&nbsp; È äÑ Ç Ñ ÇÑ Ç Ç äÇä Ç äÇ äÇ ä Çä Çä Ç ÚÈ&nbsp; â êÄâ ê âê Äâ ÄÈâ Ä âÄ âÄ â Äâ Äâ Äâ Ä âÄ â Äâ Äâ Äâ Ä âÄ&nbsp;&nbsp;&nbsp;&nbsp; åÊ æåÊ æåÊ æå Êæå Êæå ÊçÎÇ ÎçÇ Ùç ÇÙç äç äÙçÚä ÙÚçä ÙçÚä çÙä çÙä çÙ ä çÚä&nbsp; äÇ éÉäÇ ÇäÇ ÙÊÇäÇÑ ÙÚ ÙÚ </P>

[color=red]This value is shown perfectly[/color]. What I have figured out is that there is some conflict of HTML codes used above with substr and thats why it didn't show any thing. Do you have any idea what happened wit this.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.