Bonjour à tous,
J'ai un leger problème lors de l'affichage d'un tableau, je m'explique.
J'ai un tableau de commande (commandeparbudget) formé comme ceci : (var_dump de mon tableau avec les 2 premières valeurs) :
Lorsque je souhaite parcourir celui-ci dans ma vue (stats.html.twig), je fais cela :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 array(5) { [1]=> array(159) { [0]=> array(11) { [0]=> object(Cco\GestionCommandeBundle\Entity\CommandeHasArticle)#1788 (5) { ["id":"Cco\GestionCommandeBundle\Entity\CommandeHasArticle":private]=> int(17388) ["quantite":"Cco\GestionCommandeBundle\Entity\CommandeHasArticle":private]=> int(1) } ["designation"]=> string(12) "Agrafes 26/6" ["prixunitaire"]=> float(0.167) ["numordre"]=> int(1) } [1]=> array(11) { [0]=> object(Cco\GestionCommandeBundle\Entity\CommandeHasArticle)#1786 (5) { ["id":"Cco\GestionCommandeBundle\Entity\CommandeHasArticle":private]=> int(17185) ["quantite":"Cco\GestionCommandeBundle\Entity\CommandeHasArticle":private]=> int(5) } ["designation"]=> string(13) "Agrafes 8/4 " ["prixunitaire"]=> float(0.104) ["numordre"]=> int(3) } (!) La clé de ma première case du tableau correspond à un id de budget (!)
Je souhaite donc boucler sur 'j' pour parcourir toutes les cases de mon tableau mais le résultat de ceci est ... une page toute blanche ! J'ai donc consulté les log et cette erreur s'affiche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 {% for budget in lesbudgets %} <tr> <th>N° ordre</th> </tr> {% set long = commandeparbudget[budget.idbudget]|length %} {% for j in range(0, long) %} <tr> <td>{{ commandeparbudget[budget.idbudget]~'.'~j~'.numordre'}} </td> </tr> {% endfor %} {% endfor %}
Le plus étrange, c'est que lorsque je remplace {{ commandeparbudget[budget.idbudget]~'.'~j~'.numordre'}} par {{ commandeparbudget[budget.idbudget].0.numordre'}} , il m'affiche bien la bonne valeur (à savoir 1 (en gras dans le var_dump)).PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 64 bytes) in /var/www/Symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/Exception/FlattenException.php on line 264, referer: http://10.224.1.22/Symfony/web/app_dev.php/stats
Je ne comprends pas ce qu'il se passe, donc si quelqu'un pouvait m'éclairer, ce serait avec grand plaisir.
J'espere avoir été clair et reste à votre disposition pour toutes questions éventuelles.
Merci d'avance![]()
Partager