|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2017-07-23 11:29 UTC] kalle@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: kalle
[2017-07-23 11:29 UTC] kalle@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 19:00:01 2025 UTC |
Description: ------------ 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); } })($str); 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.