Jump to content

Issue in coding when using substr function


phpmady

Recommended Posts

Hi,

 

When i am getting the part of the text using the function substr, am getting this kind of problem , (text in the end not printing properly) how to solve this.

 

تسر مؤسسة مهارات التقنية ومؤسسة اشبكة الثنائية ان تطلع جميع عملاءها بإصدار نظام تاتش لإدارة الموقع الالكترونية من يوم السبت ا�

 

 

This is the code am using

$sub_string_content = substr($temp['News_Content'],0,300);

 

 

 

Thanks,

The issue arises because you have a string with multibyte characters. The normal substr() assumes that one byte equals one character. Instead,  try using mb_substr(), which is the multibyte equivalent. Make sure to specify the correct encoding. Also, it requires the mbstring extension to be loaded.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.