0

I need to send an array of arrays like:

    $arrayData = array();
    $arrayIndex = array();
    $arrayUsnm = array();
    $arrayEmail = array();

    array_push($arrayIndex, $j+1);
    array_push($arrayUsnm, $userNameFromFile);
    array_push($arrayEmail, $eMailFromFile);
    $arrayData = [$arrayIndex, $arrayUsnm, $arrayEmail];

I send to the view like:

   'datas' => $arrayData,

But this is the collection of arrays inside of array:

    [["foo1,"foo2"],["bar1","bar2"],["fo1","fo2]]

In mi twig I have:

    {% for key in datas %}
    <ul>
        <td class="col-md-3">{{ key }}</li>
        <td class="col-md-3">{{ key }}</li>
        <td class="col-md-3">{{ key }}</li>
    </ul>
    {% endfor %}

How can I access to the first array, and the second, etc ?.

Thanks in advance.

1 Answer 1

1

Use another loop for your arrays in your loop:

{% for arr in datas %}
<ul>
    {% for key in arr %}
        <li class="col-md-3">{{ key }}</li>
    {% endfor %}
</ul>
{% endfor %}
Sign up to request clarification or add additional context in comments.

Comments

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.