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}