je voudrais remplir un tableau à 2 dimensions avec que des 0 ...
Voici mon code mais ça ne marche pas !!
Code : Tout sélectionner
$resData = array () ;
for ($z ; $z < 23 ; $z++) {
for ($w ; $w < 13 ; $w++) {
$resData[$z][] = 0 ;
}
}
Code : Tout sélectionner
$resData = array () ;
for ($z ; $z < 23 ; $z++) {
for ($w ; $w < 13 ; $w++) {
$resData[$z][] = 0 ;
}
}
$resData = array () ;
for ($z = 0; $z < 23 ; $z++) {
for ($w = 0; $w < 13 ; $w++) {
$resData[$z][] = 0 ;
}
} Code : Tout sélectionner
$resData = array();
$array12 = array();
for ($f = 0; $f < 12;$f++) {$array12[] = ' ';}
for ($f = 0; $f < 23;$f++) {$resData[] = $array12;}
$tab = array();
for($i=0; $i<$nb_lines, $i++) $tab[]=array_fill(0, $nb_cols, 0);
A voir après niveau performances la meilleure méthode...
Perso, un aussi bon conseil je le mettrais en gras et en rouge. D'ailleurs je ne m'en prive pas :Faudrait penser à initialiser tes variables
error_reporting(E_ALL);
Et si ça marche, pourquoi s'arrêter en si bon chemin ?un truc comme ca, ca marche aussi
$z = 23;
$w = 13;
$resData = array_fill(0, $z, array_fill(0, $w, 0));
PS: la gestion de tableaux multidimensionnels est plutôt compliquées, si tu as d'autres bugs songe sérieusement à revoir ton design
Parce qu'il fallait y penserEt si ça marche, pourquoi s'arrêter en si bon chemin ?un truc comme ca, ca marche aussi