mb_convert_kana()
mb_convert_kana() — Convert "kana" one from another ("zen-kaku", "han-kaku" and more).
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Performs a "han-kaku" - "zen-kaku" conversion for string string. This function is only useful for Japanese.
Signature
mb_convert_kana(string $string, string $mode = "KV", ?string $encoding = null): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $string | string | The string being converted. |
| $mode | string | The conversion option. |
| $encoding | ?string | The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used. |
Return value
The converted string.
Example
A runnable snippet:
/* Convert all "han-kaku" "kata-kana" to "zen-kaku" "hira-gana" */ echo mb_convert_kana('ヤマダ ハナコ', "HV") . "\n"; /* Convert "han-kaku" "kata-kana" to "zen-kaku" "kata-kana" and "zen-kaku" alphanumeric to "han-kaku" */ echo mb_convert_kana('コウザバンゴウ 0123456', "KVa") . "\n";
Output:
やまだ はなこ コウザバンゴウ 0123456
Changelog
| Version | Change |
|---|---|
| 8.2.0 | A ValueError is now thrown if the combination of different modes is invalid. |
| 8.0.0 | encoding is nullable now. |
| 8.0.0 | Now throws a ValueError if encoding is an invalid encoding. Previously, an E_WARNING was emitted and false was returned. |
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_convert_kana() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.