|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69512 No multibyte strrev function
Submitted: 2015-04-23 13:02 UTC Modified: 2015-04-23 15:36 UTC
Avg. Score:4.0 ± 1.3
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:3 (60.0%)
From: 550794054 at qq dot com Assigned:
Status: Open Package: mbstring related
PHP Version: 5.6.8 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: 550794054 at qq dot com
New email:
PHP Version: OS:


 [2015-04-23 13:02 UTC] 550794054 at qq dot com
From manual page:
I find the instruction "strrev" cannot support non-English string,if want to reverse like chinese string ,Janpanese string,or Russian string,"strrev" will display gibberish.even add Prefix "mb_" also not support.

Test script:
echo $str1;

Expected result:
maybe it's the problem belongs to C.but I also want to PHP group can fix the problem. Thank you! 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-23 13:14 UTC]
-Summary: "strrev" cannot support non-English string +Summary: No multibyte strrev function -Package: PHP Language Specification +Package: Strings related
 [2015-04-23 13:14 UTC]
strrev(), like most other string functions, operate on bytes. They are not suitable for multibyte strings.

There is no "mb_strrev" function so I'm turning this ticket into a feature request for one.
Meanwhile the best option *for UTF-8 strings* I can think of is to use preg_split() or _match() with /u to split the input into characters, reverse the array, and implode() them back together.
 [2015-04-23 13:14 UTC]
-Package: Strings related +Package: mbstring related
 [2015-04-23 13:20 UTC]
A mb_strrev would not necessarily give the desired results, because
the mb_* functions work on code points (when dealing with UTF-8),
what doesn't cater to combining chars. A grapheme_strrev would be
more useful.
 [2015-04-23 15:36 UTC] 550794054 at qq dot com
Thanks for reply me.I'm a begin PHP learner.I also konw it's can use the regular expression can deal with the problem.But it's so hard.I think if there can be an instruction can use,it will be better.Because there come to "mb_subtr()","mb_strpos()","mb_strstr()",why just add "mb_strrev"?
it's just my advice,thanks again for reply me.
 [2019-02-01 00:42 UTC] sound1st dot piano at gmail dot com
PHP must implement a function like:

mb_strrev ( string $string [, string $encoding = mb_internal_encoding() ] ) : string

It is out of the question that a programming language cannot support multibyte encodings fully in this day and age.

 [2022-12-28 10:11 UTC] amin dot jabari242 at gmail dot com
The solution worked for me ok  to the community and the members for the solution. (
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 05:01:35 2024 UTC