mysql - Put the contents of file into an array with delimiter and store it in a database (php) -
this code can read file , put array, without separator. not insert database.
example : marck ; frauss
marck firstname (varchar) , frauss lastname (varchar)
please help.
class fichier { var $fichier; var $handle; function fichier($chaine) { $this->fichier = $chaine; } function open() { $this->handle = @fopen($this->fichier,"r" ); } function recupligne() { $buffer = fgets($this->handle, 4096); return $buffer; } function stock() { $this->open("r" ); if ($this->handle) { $tab = array(); while (!feof($this->handle)) { $ligne = $this->recupligne(); $tab[] = $this->traitement($ligne); } $this->close(); return $tab; } } function traitement($chaine) { // fonction éventuelle de traitement return $chaine; } } $monfichier = new fichier("montexte.txt" ); $montableau = $monfichier->stock();
Comments
Post a Comment