我有以下代码,它们使用PHP的codeigniter读取CSV文件:
//Upload to server:
$config['upload_path'] = './tmp/';
$config['allowed_types'] = 'gif|jpg|png|doc|txt|csv';
$config['max_size'] = 1024 * 8;
$config['encrypt_name'] = TRUE;
$csv_move_path = $this->config->item('directory')."/destination/";
$this->load->library('upload', $config);
$this->upload->do_upload('name_of_csv');
$this->upload->data();
move_uploaded_file($_FILES["file"]["tmp_name"], $csv_move_path . $_FILES["file"]["name"]);
$path = $csv_move_path . $_FILES["file"]["name"];
//Reading CSV
$fields; /** columns names retrieved after parsing */
$separator = ';'; /** separator used to explode each line */
$lines = file($path);
//Loop of lines
foreach( $lines as $line_num => $line )
{
if(!empty($line)){ // skip empty lines
$content = explode($separator, trim(str_replace('\'', '', $line)));
//Save line on DB
$this->model->addInformation($header_array,$content);
}}
我的问题是,当我有一个很长的数字时它会自动转换为科学记数法,所以当我用PHP读取它需要3,53E + 14而不是352564000000000时,有人可以帮助我如何读取整个数字而不是科学记数法?
PS:我已经使用Excel
将字段转换为CSV文件上的文本