php - TWIG:从字符串中修剪两个字符
问题描述
解决方案
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.
推荐阅读
- c# - C# WebMethod - 更改字符串列表的参数名称
- x86 - RFO 计算英特尔 CPU 上的原子添加操作和缓存线锁定?
- javascript - jQuery 多步向导表单
- javascript - 我可以使用 createElement 创建自闭合元素吗?
- javascript - Javascript“变量”未定义
- android - (Unity) 如何在Android上读取旧游戏数据?
- r - 将对象作为函数参数列出,具有可覆盖的列表元素默认值
- magento2 - Magento 和 mandrill smtp 标头
- cakebuild - 使用 Cake build 整合包
- java - 使用 java scoket 在接收到的文件中获取额外的字节