|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73066 mb_at and mb_codepoint_at
Submitted: 2016-09-12 08:40 UTC Modified: 2017-07-23 11:29 UTC
From: masakielastic at gmail dot com Assigned: kalle (profile)
Status: Closed Package: mbstring related
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 10 = ?
Subscribe to this entry?

 [2016-09-12 08:40 UTC] masakielastic at gmail dot com
I propose mb_at and mb_codepoint_at.

string mb_at ( string $string , int $offset [, string $encoding = mb_internal_encoding() ] )
int mb_codepoint_at ( string $string , int $offset [, string $encoding = mb_internal_encoding() ] )

The one of usage of these functions is to iterate over all the chars in string.

$str = "Cat!\u{1f431}";

$gen = (function($str) {
    for ($i = 0, $len = mb_strlen($str); $i < $len; ++$i) {
        yield mb_at($str, $i);

foreach ($gen as $char) {
    echo $char, PHP_EOL;

mb_codepoint_at is equivalent to the following code:

mb_ord(mb_substr($str, $i, 1));

str_at and str_codepoint_at are worthy of consideration.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-23 11:29 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2017-07-23 11:29 UTC]
Please re-open if you are picking back up the PR, thanks!
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jan 27 05:04:15 2023 UTC