« iconv_set_encoding
iconv_strpos »

iconv_strlen

(PHP 5, PHP 7, PHP 8)

iconv_strlen — 文字列の文字数を返す

説明

function iconv_strlen(string $string, ?string $encoding = null): int|false

strlen() とは違い、iconv_strlen() は与えられたバイト列 string 中に現れる文字の数を 指定された文字セットに基づいて数えます。この結果は、必ずしも文字列の バイト数と一致するとは限りません。

パラメータ

string

文字列。

encoding

encoding パラメータが指定されなかった場合、もしくは null の場合、 string のエンコードは iconv.internal_encoding であると判断されます。

戻り値

string の文字数を返します。 処理中にエラーが発生した場合は false を返します。

変更履歴

バージョン 説明
8.0.0 encoding は、nullable になりました。

参考

関連キーワード:
iconv   strlen   encoding   文字数   バイト   strpos   セット   一致   エンコード   internal   判断   処理中   履歴   nullable   参考   grapheme   書記素   単位
関連する関数・ページ:
function.iconv-set-encoding   function.strlen   function.mb-strlen   ref.iconv   function.iconv-get-encoding   function.ob-iconv-handler