Search code examples
phptwigfuelphp

how to split character in Twig template?


i'm having a problem when i want to use split function in Twig, i have words like this Male\tDoctor ,i want to split that word using \t ascii,

i'm search in search engine and i'm get a discussion about twig split issue in this url i'm read that and i think the problem is fixed, but when i'm search in twig website documentation, i can't found filter function by split you can read this.

and when i'm try using this code

{{ var | split('\t') }) 

the return is The filter "split" does not exist

do you have any idea or some suggestion for solve this problem ?

thanks for your answer...:)

Note :
i'm using fuelphp framework & twig template


Solution

  • just for completeness:
    the PR mentioned by F21 is merged now (since 19.10.2012) and twig supports split: http://twig.sensiolabs.org/doc/filters/split.html

    {{ "one,two,three"|split(',') }}
    {# returns ['one', 'two', 'three'] #}