问问题
2996 次
2 回答
1
Use php str_replace
str_replace([",", "₹"], "", $str);
replace for twig
{% if foo |replace({'₹':'', ',':''}) |number_format > 3000 %}
https://twig.symfony.com/doc/2.x/filters/replace.html
So how you would ideally do it would be pass in just a regular integer to your twig template, do the comparison & then if you need to display the whole string on the page, prefix the number_format
to get the comma and if you wish decimal places.
于 2018-11-14T18:23:56.093 回答
1
正如评论中提到的,这不是视图的工作。但replace
过滤器可以这样做:
{% if foo |replace({'₹':'', ',':''}) > 3000 %}
您不想使用number_format
过滤器,因为这只会重新引入标点符号。
于 2018-11-14T18:26:38.697 回答