如何防止php将字符串转换为整数/浮点数?

时间:2015-06-19 14:04:39

标签: php string integer

我正在尝试处理/解析包含产品UPC代码的文本文件。每次我读取文件时,我的UPC都会转换为指数表示法。我怎么能阻止这个? (我尝试过settype()但是会被忽略。)

<?php
//input: 46563,,840253044815,106 12200-0 3-WAY LAMP ASTON BRONZE 29x21x16 1-150M,07/06/2007,07/06/2007,NONSTOCK,0,0,,AMBIENCE,AMBIENCE
$lines = file ('./scripts/fullproductlist.csv');
$newlinedata = "";
$count = 0;
// Loop through array, 
foreach ($lines as $line) {
    settype($linedata, "string");
    $linedata = explode (",", "$line");
    $count1++;
    echo "Line:".$count1."::".$line."\n"; //Output new line
}
    //output: 46563,,8.40253E+11,106 12200-0 3-WAY LAMP ASTON BRONZE 29x21x16 1-150M,7/6/2007,7/6/2007,NONSTOCK,0,0,,AMBIENCE,AMBIENCE
?>

0 个答案:

没有答案