カテゴリー:Smarty
Smartyで数字の文字列のフォーマットを整える
![](https://univetech.com/cosmo-wp/wp-content/themes/blogpress_tcd10/img/common/no_image1.gif.pagespeed.ce.paA5GVFLtg.gif)
Smartyで数字の出力を色々と指定したい場合がある。その場合には、以下のようにすればよい。{$num1|string_format:"%05d"}{$num2|string_format:"…
詳細を見るSmartyで数値を3桁ごとにカンマを付けたい
![](https://univetech.com/cosmo-wp/wp-content/themes/blogpress_tcd10/img/common/no_image1.gif.pagespeed.ce.paA5GVFLtg.gif)
1234567とある数字を1,234,567とSmartyで表示したい場合は、以下のようにすればOK!{$num|number_format}…
詳細を見るSmartyで文字列の抽出(substr)
![](https://univetech.com/cosmo-wp/wp-content/plugins/lazy-load/images/1x1.trans.gif.pagespeed.ce.2JdGiI2i2V.gif)
Smartyのテンプレートにて、phpのsubstr()的なことをしたい場合の備忘録。{$yyyymm|substr:0:4}年{$yyyymm|substr:5:2}月とすればOK!文責:牧秀樹…
詳細を見るSmarty 日付フォーマット
![](https://univetech.com/cosmo-wp/wp-content/themes/blogpress_tcd10/img/common/no_image1.gif.pagespeed.ce.paA5GVFLtg.gif)
Smartyのテンプレートで日付を表示させたい場合、通常のPHPとはやや構文が異なる。この違いはよく忘れるのでメモ。下記は、$any_date = '2014-02-04 15:45:20';をテンプレートに渡していることを…
詳細を見る文字列を指定の形式にフォーマットする(Smarty)
![](https://univetech.com/cosmo-wp/wp-content/plugins/lazy-load/images/1x1.trans.gif.pagespeed.ce.2JdGiI2i2V.gif)
Smartyにおける文字列、特に数値を含む文字列の出力形式を指定する方法。「string_format」を使う。具体的には次のように記述する{$num_str|string_for…
詳細を見る