twig - How to print value with dynamic variable -


datas

$datas = [     'first' => [         1 => [             'count' => 20         ],         2 => [             'count' => 100         ]     ] ]; 

i have data load database, result like:

$rows = [     1 => 'aaaa',     2 => 'bbbb' ]; 

i loop rows in view

{% key, row in rows %}     {{ datas.first.key.count }} // empty {% endfor %} 

i want use rows key show datas count, it's not work, datas.first.1.count print correct result

in php

$datas = [     'first' => [         1 => [             'count' => 20         ],         2 => [             'count' => 100         ]     ] ];  $rows = [     1 => 'aaaa',     2 => 'bbbb' ];  foreach ($rows $key => $value) {     echo 'count :'.$datas['first'][$key]['count']; } 

this sample on php

i think (not clear) want this:

{% row in datas.first %}     {{ row.count }} // count value {% endfor %} 

here working twigfiddle:

https://twigfiddle.com/6yup1l


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -