Bonjour,
je récupère dans un tableau $actus une liste d'actualités sous la forme :
L'idée serait d'afficher la liste des actualités dans le genre :
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 array(8) { [0]=> array(2) { ["texte_actus"]=> string(9) "long text" ["date_actus"]=> string(10) "2023-06-25" } [1]=> array(2) { ["texte_actus"]=> string(7) "bla bla" ["date_actus"]=> string(10) "2023-06-27" } [2]=> array(2) { ["texte_actus"]=> string(17) "texte à rallonge" ["date_actus"]=> string(10) "2023-06-27" } etc }
autrement dit d'afficher les éléments du tableau $actus. Comme je sais mal parcourir un tableau multidimensionnel, j'ai commencé par ce code (provisoire) :25 juin 2023 long text 27 juin 2023 bla bla 27 juin 2023 texte à rallonge etc$id[$key] n'est visiblement pas bon :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 foreach($id as $key => $value){ echo $key. " :<br>"; if(is_array($value)){ foreach($value as $key => $value){ echo $key." : ".$id[$key]."<br>"; } } echo "<br>"; }
Comment faire SVP ?0 :
Warning: Undefined array key "texte_actus" in C:\projets\arnaudpoo\src\view\block\DispActus.php on line 5
texte_actus :
Warning: Undefined array key "date_actus" in C:\projets\arnaudpoo\src\view\block\DispActus.php on line 5
date_actus :
etc
Partager