Iterating Multibyte Strings
Learn how to iterate multibyte strings in PHP with the help of practical examples.
We'll cover the following
UTF-8 string iterator implementation contains the full implementation for the class we will develop throughout this chapter.
Issues with multibyte iteration
In the previous lesson, we implemented several string functions that worked by iterating a string’s characters. Treating each byte as a single character is fine when working with ASCII, but as soon as we need to work with multibyte characters, things become a little more complicated. As an example, if we attempted to iterate “這可以” using the following. After pressing the “Run” button, the output can be viewed by clicking the app link under the “Run” button
Get hands-on with 1400+ tech skills courses.