PHP: 2010年6月アーカイブ


/**
 * 半角数字→全角数字に置き換えるmodifier
 *
 * @see
 * http://pentan.info/php/smarty/mod_hkana.html
 *
 */
function smarty_modifier_numeric_hantozen($string, $encoding = 'UTF-8')
{
    return mb_convert_kana($string, "N", $encoding);
}

使い方

ファイル名を "modifier.numeric_hantozen.php" にして、Smartyのプラグインディレクトリに保存してください。

テンプレート内で、下記のようにと書くと変換してくれます。

{$number|numeric_hantozen}

参考記事
携帯表示用に文字を全角から半角にする - [Smarty] ぺんたん info

このアーカイブについて

このページには、2010年6月以降に書かれたブログ記事のうちPHPカテゴリに属しているものが含まれています。

前のアーカイブはPHP: 2010年5月です。