I'm importing an Excel file.
The file has mixed data types - item code, currency values, dates.
The item codes can have leading zeroes, so I'm using:
$objPHPExcel->getActiveSheet()->toArray('', false, true, false);
As you would expect, this is retaining the leading zeroes, and is also retaining number formatting: 12,345.00
The problem is that we need certain numbers in float format, to perform operations on them.
For some reason, PHP isn't performing implicit type conversion.
e.g.:
$value = "21,356.00";
$newvalue = $value * 2;
This returns: 42. I expected it to return 42712.00.
Why is this happening?
With the excel file, we only know which column contains the item codes. The other columns can be anything, so I can't just parse float across them all. We identify them by the header row in the file.
Ideally we need to implicit type conversion to work.
Any suggestions?