L
L
lemburov2015-02-01 22:04:05
Twig
lemburov, 2015-02-01 22:04:05

How to pass 2 dependent arrays to TWIG?

Hello, I've just started learning Twig template engine. The following question arose:
When accessing the database, I form an array $data_profit[]

$cat_profit=DB::run()->query("SELECT * FROM `user_cat_profit` WHERE `id_user`='".$_SESSION['id_user']."' AND `del`='0' ORDER BY `id_cat_profit` DESC");
while($data=$cat_profit->fetch())
{
$uncat_profit=DB::run()->querySingle("SELECT * FROM `user_uncat_profit` WHERE `id_user`='".$_SESSION['id_user']."' AND `del`='0' AND `id_cat_profit`='".$data['id_cat_profit']."'");
$data_profit[]=$data;
}

I understand how to transfer only this array to Twig, but what about the $uncat_profit variable, it is clear that you also need to make an array out of it, but how to form it correctly?
And how then to parse these arrays in Twig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergeyj, 2015-02-01
@sayber

Parse with for

{% for item in items %}
  {{item.value}}
{% endfor %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question