I build a class which contruct an HTML array from an PhP array
the class count how many row and how many col it needed.
to do, i use end and key function (for the event a col or a row not been set)
i give the array to the constructor.
if the first cell of the array ( [0][0] ) is set, everything is well,
but if it is not the key function return nothing !
so i try in the constructor to set the [0][0] cell but it doesn't work Too
how i can do ?!?
/******************************************/
function TAB($tab,$titre,$bkg_color,$bkg_color_titre)
{
if(is_array($tab))
{
/ maj propriete objet */
echo "tab[1][0]=".$tab[1][0]."<BR>\n";
$tab[0][0]=0;
$this->tab=$tab;
echo "this->tab[1][0]=".$this->tab[1][0]."<BR>\n";
$this->titre=$titre;
$this->bkgcolor=$bkgcolor;
$this->bkg_color_titre=$bkg_color_titre;
// $this->width="100%";
next($tab);end($tab);$this->nbr_l=key($tab); //recupere nbr ligne
echo "this->nbr_l=".$this->nbr_l."<BR>";
next($tab);end($tab[0]);$this->nbr_c=key($tab[0]); //recupere nbr colonne
echo "this->nbr_c=".$this->nbr_c."<BR>";
if($this->nbr_c==0) //si pas 2 dimensions
{unset($this->nbr_l);}
// echo "couleur=$TAB_bkg_color & couleur2=$TAB_bkg_color_titre<BR>\n";
// echo "tableau de $TAB_nbr_l * $TAB_nbr_c<BR>\n";
}
else
{$this->erreur="<B>CLASSE TAB ERREUR:</B>la variable $tab n'est pas un tableau !!!";}
}