<?php /** * 全角単位で文字数を取得する * @param $str 文字列 * @return int 全角単位での文字数 */ function getZenLen($str) { // 内部エンコーディングが utf-8 の場合 return mb_strwidth($str, 'utf-8') / 2; }
常識だったらすみません。
ウェブサービスを作っています。
<?php /** * 全角単位で文字数を取得する * @param $str 文字列 * @return int 全角単位での文字数 */ function getZenLen($str) { // 内部エンコーディングが utf-8 の場合 return mb_strwidth($str, 'utf-8') / 2; }
常識だったらすみません。