création de table (array) et Affectater les valeurs de table dans différentes variables
Bonjour,
J'ai un tableau dans un fichier TXT:
Citation:
"nom","prenom","email","id"
"moto","toto","moto@toto.com","1255"
"po","to","to@to.com","1254"
"abtoto","ermoto","abtoto@cocooto.com","325"
"cdtoto","tymoto","cdtoto@rororoto.com","25"
Je veux transformer dans un array pour obtenir les variables: $nom, $prenom, $email, $id
Comment je peux donner les bonnes valeurs aux mes variables ci-dessus ?:calim2:
Alors il faut que j'obtienne quelques choses comme cela :
Code:
1 2 3 4 5 6
| $maTableTxt = array(
1 => array('nom' => 'moto', 'prenom' => 'toto', 'email' => 'moto@toto.com', 'id' => '1255'),
2 => array('nom' => 'po', 'prenom' => 'to', 'email' => 'to@to.com', 'id' => '1254'),
3 => array('nom' => 'abtoto', 'prenom' => 'ermoto', 'email' => 'btoto@cocooto.com', 'id' => '25')
//etc....
); |
Comment puis-je faire ?:oops:
je fais cela mais je n'arrive pas :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $filetxt = 'test.txt';
$maTableTxt = array();
$lines = file($filetxt, FILE_IGNORE_NEW_LINES);
foreach ($lines as $lineNumber => $lineContent){
foreach($maTableTxt as $cle => $valeur){
foreach ($valeur1 as $cle2=>$valeur2){
$contenuChaqueLine = str_replace ( '"' , '' , $lineContent );
echo $contenuChaqueLine; // pour voir si cela marche
}
}
} |
Mais echo n'affiche rien.:cry:
Où je fais des fautes ?
Merci et bonne soirée
Merci