1

I am parsing CSV's and I am having no problem reading the CSVs. The only problem is if the CSV has a negative number ex: -154.64 keeps coming back without the - and it's putting parenthesis around it: (154.64).

I need the correct way to turn this parenthesis number back into a negative number. I am inserting these numbers into my DB and if I try and put the (154.64) it just puts a positive number in the DB 154.64.

Thanks!

EDIT

Using Parse CSV

$csv = new parseCSV($_FILES['csvUpload']['tmp_name']);

foreach( $csv->data as $row ) :
print_r($row);
endforeach;

If there is a negative number it will show:

array (
  margin => (123.65)
)

I Need

array (
  margin => -123.65
)
Taylor Foster
  • 1,103
  • 1
  • 11
  • 24
  • Please post an excerpt from the csv file you are using and the code you are using to parse it. – TheGentleman Jul 19 '17 at 16:16
  • Try using PHP's built in csv functions. [fgetcsv](http://php.net/manual/en/function.fgetcsv.php) should be of particular interest to you. Examples are also provided on that link. – coderodour Jul 19 '17 at 16:24
  • PHP has built-in support for CSV. See [this answer](https://stackoverflow.com/questions/9139202/how-to-parse-a-csv-file-using-php) for more details... – War10ck Jul 19 '17 at 16:30

0 Answers0