Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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, ";", "'")
);
}
}
@thukabjj

This comment has been minimized.

Copy link

commented Dec 29, 2017

Cria um contador fora do do com o valor true ai dentro do if você coloca & isset($contador) and $contador === true{ continue;}else{codigo}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.