ConFoo Montreal 2026: Call for Papers

Voting

: min(three, four)?
(Example: nine)

The Note You're Voting On

Quicker
14 years ago
If you need to parse utf-8 strings char by char, try this one:

<?php
$utf8marker
=chr(128);
$count=0;
while(isset(
$string{$count})){
if(
$string{$count}>=$utf8marker) {
$parsechar=substr($string,$count,2);
$count+=2;
} else {
$parsechar=$string{$count};
$count++;
}
/* do what you like with parsechar ... , eg.:*/ echo $parsechar."<BR>\r\n";
}
?>

- it works without mb_substr
- it is fast, because it grabs characters based on indexes when possible and avoids any count and split functions

<< Back to user notes page

To Top