php - How to add a delimiter in twig to a string? -



php - How to add a delimiter in twig to a string? -

i have time in format hhmm string , add together " : " after hours. there simple filter split string after 2 characters , add together delimiter?

you can split position this

{% set bar = "aabbcc"|split('', 2) %} {# bar contains ['aa', 'bb', 'cc'] #}

as described in doc

so can like:

{% set bar = "1203"|split('', 2) %} {# bar contains ['12', '03'] #}

now let's do:

{{ bar[0]~":"~bar[1] }}

this output:

12:03

better if build macro or twig extension function

hope help

php symfony2 twig

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -