PHP 8.5.0 RC 2 available for testing

Voting

: max(five, one)?
(Example: nine)

The Note You're Voting On

Hayley Watson
6 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

AltStyle によって変換されたページ (->オリジナル) /