php dbase extension cutting off float point numbers
Domanda
I have weird problem with php reading dbase (dbf) files.
My development environment
- OS: Win 7
- Php version: 5.3.8
- Web server: apache 2.2
My production environment
- OS: Centos 5.5
- Php version: 5.3.12
- Web server: nginx 1.2.1
Both those environments use standard php dbase extension (unix: http://pecl.php.net/package/dbase, win: http://downloads.php.net/pierre/).
I have dbf file where one column is float (10,2) with value, lets say, 26.14. When I read this file in my development environment it shows correctly ("26.14"), but doing the exact same operation on production environment it outputs just "26". Code follows:
<?php
$db = dbase_open($path_to_dbf, 0);
$record_numbers = dbase_numrecords($db);
for ($i = 1; $i <= $record_numbers; $i++)
{
$row = dbase_get_record_with_names($db, $i);
echo '<pre>', var_dump($row), '</pre>';
}
?>
I'm really confused and don't know where to start looking for solution to this problem. Can anyone help, please?
Soluzione
I know this is old question, but maybe it'll help someone.
Probably you have an "," as separator, instead of "."
I have that problem and this helps:
setlocale(LC_NUMERIC, 'C');