1

I've got a variable that outputs a string such as:

question ^ answer > question ^ answer > question ^ answer

Now, I added the symbols in between them to know where the split should happen. I've been using the 'Explode' plugin (http://devot-ee.com/add-ons/explode) and this works perfectly. BUT it only works to split based on one set of characters e.g. ^ only.

{variable} = question 1 ^ answer 1 > question 2 ^ answer 2

{exp:explode separator=">" string="{variable}"}

    <div id="question">
        {exp_value}
    </div>

 {/exp:explode}

The above code would output:

    <div id="question">
        question 1 ^ answer 1
    </div>

    <div id="question">
        question 2 ^ answer 3
    </div>

Which is great, but I need my markup to be like this:

    <div id="question">
        question 1
    </div>

    <div id="answer">
        answer 1
    </div>

Which would require doing something like:

{variable} = question 1 ^ answer 1 > question 2 ^ answer 2

{exp:explode separator="^|>" string="{variable}"}

    <div id="question">
        {exp_value_1}
    </div>

    <div id="answer">
        {exp_value_2}
    </div>

 {/exp:explode}

Which would then output:

    <div id="question">
        question 1
    </div>

    <div id="answer">
        answer 1
    </div>

    <div id="question">
        question 2
    </div>

    <div id="answer">
        answer2
    </div>

Now the Explode plugin comes with the {exp_value_1} and {exp_value_2} variables, but they don't work on a 'Loop'

Is there any way of achieving this? With any other plugin? Or another solution

1

I think you can do this with the Lists feature of CE Variables.

http://www.causingeffect.com/software/expressionengine/ce-variables/user-guide/lists

| improve this answer | |
  • I'll give this a go. It certainly looks like it might work. – Jason Mayo Jul 18 '13 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.