LoginSignup
4
4

More than 5 years have passed since last update.

PHPでUTF-8の文字列をマルチバイト、シングルバイト問わず1文字ずつ取得する

Last updated at Posted at 2013-07-02
split.php
<?php
$text = "テキストtextテxト";
$encoding = "UTF-8";

$textLength = mb_strlen($text, $encoding);

for($i = 0; $i < $textLength; $i++) {
    echo mb_substr($text, $i, 1, $encoding)."\n";
}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4