Will it make any difference or impact on my result, if I use substr() instead of mb_substr() function?

As my server does not have sầu support for mb_ functions, I have sầu lớn replace it with substr()

Bạn đang xem: Get part of string



It will impact your script if you work with multi-byte text that you substring from. If this is the case, I higly recommend enabling mb_* functions in your php.ini or vày this ini_set("mbstring.func_overload", 2);


If you have sầu utf-8 encoding use mb_substr

Example :

eđến substr("hi mémé", 0 , 5); // will print hi m�emang đến mb_substr("hi mémé", 0 , 5); // will print hi mé


Xem thêm: đổi tên file upload trong php

string substr ( string $string , int $start <, int $length > )

Returns the portion of string specified by the start & length parameters.

string mb_substr ( string $str , int $start <, int $length <, string $encoding >> )

Performs a multi-byte safe substr() operation based on number of characters. Position is counted from the beginning of str. First character"s position is 0. Second character position is 1, and so on.


Thanks for contributing an answer to Staông chồng Overflow!

Please be sure to answer the question. Provide details và share your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; baông xã them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Disthẻ

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged php string multibyte or ask your own question.

site design / biểu tượng logo © 2021 Stachồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.8.5.39930

Your privacy

By clicking “Accept all cookies”, you agree Staông xã Exchange can store cookies on your device và discthất bại information in accordance with our Cookie Policy.