Voting

: three plus one?
(Example: nine)

The Note You're Voting On

Hayley Watson
5 years ago
Assuming you're using UTF-8, this function can be used to separate Unicode text into individual codepoints without the need for the multibyte extension.

<?php

preg_split
('//u', $text, -1, PREG_SPLIT_NO_EMPTY);

?>

The words "English", "Español", and "Русский" are all seven letters long. But strlen would report string lengths 7, 8 and 14, respectively. The preg_split above would return a seven-element array in all three cases.

It splits '한국어' into the array ['한', '국', '어'] instead of the 9-character array that str_split($text) would produce.

<< Back to user notes page

To Top