とある技術者の備忘録的情報

文字列を指定の形式にフォーマットする(Smarty)

Smartyにおける文字列、特に数値を含む文字列の出力形式を指定する方法。

 

「string_format」を使う。

 

具体的には次のように記述する

{$num_str|string_format:"%05d"}

こうすると、$num_strに”123″という文字列数字が入っている場合、”00123″と表示される。

 

 

文責:牧秀樹

関連記事

コメント

  1. I saw this blog through Facebook (one of my friends posted it). After reading, I clicked Like and also reshared it myseld. Anunturi Romania

  2. Hi. I just noticed that your web site looks like it has a few code errors at the very top of your website’s page. I’m not sure if everybody is getting this same bugginess when browsing your site? I am employing a totally different browser than most people, referred to as Opera, so that is what might be causing it? I just wanted to make sure you know. Thanks for posting some huge postings and I’ll try to return back with a completely different browser to check things out!

  3. this is a greatly compelling dispatch, tender thanks you for the benefit of the information. Pitiful my english is not the very best. do you remember if it is practicable to turn this to the spanish language. that would be very helpfull.

  1. この記事へのトラックバックはありません。

スポンサードリンク