0

Hello I've got a php array $arrayTitle that I have coverted into Twig:

echo $twig->render('newline.twig', array(
'allTheTitles' => $arrayTitle ));

and I want Twig to iterate the array:

{% for i in allTheTitles %}
<option>{{ i.allTheTitles }}</option>
{% endfor %}

unluckily this is the effect I get:

 <select>
  <option></option>
  <option></option>
 </select>

so it's as if Twig understood that it's an array and it guessed its lenght (2) but for some incomprehensible for me reason it doesn't return the values of the array. What do I do wrong here?

1
  • should it just be {{ i }} perhaps? since i is representing the current iteration value Commented Sep 12, 2020 at 9:21

1 Answer 1

1

Use like below

{% for i in allTheTitles %}
<option>{{ i }}</option>
{% endfor %}

If not works then , share value of $arrayTitle ?

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.