Hamid hd
Hamid hd

Reputation: 103

How to remove unwanted character from end of string?

In some cases when I use substr() function, it returns this char � at the end of returned string.

  $descrSh=substr($str,0,250);

How to solve this problem ???

Upvotes: 1

Views: 76

Answers (1)

JustOnUnderMillions
JustOnUnderMillions

Reputation: 3795

Your substr cuts an multi-byte char in half! Use mb_substr() instead.

mb_substr($str,0,250, 'utf-8')

Upvotes: 1

Related Questions