string_format
変数の値を10進数として表示したり、文字列をフォーマットして表示します。
フォーマット文字列にはsprintfの構文を使用して下さい。
例 5-17. string_format
<?php
$smarty = new Smarty; $smarty->assign('number', 23.5787446); $smarty->display('index.tpl');
?>
|
index.tpl :
{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"} |
出力 :
|