23

I've an array titled $preview_data assigned to smarty template as follows:

Array
(
  [applicable_states] => Array
        (
            [0] => 1
            [1] => 3
            [2] => 4
            [3] => 10
            [4] => 11
        )

)

Now I want to show the above array elements as comma separated values in a div element of a smarty template. In short it should behave like implode() in php. Can someone please help me in achieving this in smarty template? Thanks in advance.

3
  • is that what you are looking for smarty.net/forums/viewtopic.php?p=53566 Commented Apr 26, 2014 at 3:30
  • 5
    Did you try {', '|implode:$array['applicable_states']}? Commented Apr 26, 2014 at 3:31
  • @AmalMurali:It's working perfect for me after doing some modification. Thanks for your help. Commented Apr 26, 2014 at 3:44

1 Answer 1

49

Try this:

{', '|implode:$preview_data.applicable_states}

It will give you what you are expecting. Cheers!!!

Sign up to request clarification or add additional context in comments.

1 Comment

You saved my day but aren't here anymore to get my gratitude :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.