如何在 Twig 中使用 sprintf 来格式化数字? [英] How to use sprintf in Twig to format a number?

查看:31
本文介绍了如何在 Twig 中使用 sprintf 来格式化数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像这样格式化一个数字:

I need to format a number like this:

sprintf("%05d",$lineNumber)

但我在 Symfony2 Twig 模板中.那我该怎么办?

But I'm inside a Symfony2 Twig template. So what can I do?

推荐答案

Twig 提供了很多 过滤器,看看formatnumber_format.

Twig provides lots of filters, take a look at format and number_format.

这篇关于如何在 Twig 中使用 sprintf 来格式化数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆