Created
December 29, 2017 13:24
-
-
Save mvnp/5260725cb9304cbba7b88bf1524a3953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function csv(){ | |
if( isset($_POST['enviar_csv']) && count($_FILES['userfile']['name']) > 0 ){ | |
// ... | |
$file = $_FILES['userfile']['tmp_name']; | |
$handle = fopen($file, "r"); | |
$data = []; | |
// Loop through the csv file and insert into database | |
do { | |
if ( isset($data[0]) ) { | |
$array = array( | |
"idcas" => $this->uri->segment(3), | |
"nomenclatura" => trim(addslashes($data[0])), | |
"adultos" => trim(addslashes($data[1])), | |
"criancas" => trim(addslashes($data[2])), | |
"observacao" => trim(addslashes($data[3])), | |
"cadastro" => date("Y-m-d H:i:s"), | |
"confirmado" => 0, | |
); $this->db->insert('rsvp_convidados', $array); | |
} | |
} while ( | |
$data = fgetcsv($handle, 1000, ";", "'") | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cria um contador fora do do com o valor true ai dentro do if você coloca & isset($contador) and $contador === true{ continue;}else{codigo}