Bonjour à tous!
Voilà jai un petit problème en php :
j'ai un tableau à deux dimension donc je voudrai ssupprimer et/ou insérer des lignes !
voici mon code d'initialisation :
Code :
$cpt = 0;
while($row = mysql_fetch_array($result))
{
$tableau[$cpt][0]=$row['debut'];
$tableau[$cpt][1]=$row['heure_fin'];
$tableau[$cpt][2]=$row['idtype_temps'];
$tableau[$cpt][3]=$row['num_dossier'];
$tableau[$cpt][4]=$row['duree'];
$cpt++;
}
Vous remarquerez que mes données proviennent d'une requetes mysql.
voici ma fonction d'insertion :
Code :
function tab_insert($tab,$ligne,$indice)
{
global $tab;
$tab1 = array_slice ($tab, 0, $indice);
$tab2 = array_slice ($tab, $indice);
array_push ($tab1, $ligne);
$tab = array_merge ($tab1, $tab2);
}
voici comment j'appel ma fonction :
Code :
tab_insert($tableau,$ligne,2)
$ligne est un tableau de 5 colonne que je veux ajouter.
Lorsque j'execute un tel script, la fonction array_slice plante en me
disant que $tab doit être du type tableau. Or lorsque je teste sont
type dans la fonction, $tab est bien du type tableau.
Donc soit j'utilise mal ma fonction ou alors arry_slice. Ou alors array_slice ne marche qu'avec des tableaux à une dimension.
Merci d'avance pour votre aide.
ps : Si mes information ne sont pas assez claires ou trop peu abondante dites le.
Dieu a créé l'Homme!
L'Homme a créé la programmation!
Et la prog ...
Bah on attend!!!
