Results 1 to 4 of 4

Thread: PHP 5.2 is treating negative numbers as strings

Hybrid View

  1. #1
    Join Date
    Apr 2010

    PHP 5.2 is treating negative numbers as strings


    Thankyou for reading.

    Im pulling numbers off of a csv file.

    In PHP 5.4 there isnt a problem.

    In PHP 5.2 on a linux server that i have no means of access, -100.00 is not seen as numeric, is displayed as (100.00) and if i try and typecast or add/subtract etc it becomes 0.

    Really suspect its a bug with this PHP release but im stuck with it!

    Can anyone offer any suggestions? Google for the first time ever re: PHP came up empty! Surely im not the only one who has encountered this issue.

    Please help!

  2. #2
    Join Date
    Aug 2004
    Any chance you're depending on the (optional) 5th parameter to fgetcsv()? It was added in 5.3.0.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Apr 2010
    Definately the "" which is causing the grief with 5.2

    They are added by excel since they are formatted as currency(, in thousands)

  4. #4
    Join Date
    Apr 2010
    Just using while (($data[$row] = fgetcsv($handle, 0, ",")) !== FALSE) {

    Have noticed after openign the csv in notepad++ that the negative numbers are bracketed with "

    Going to try file get contents instead. Really just grasping at any straws at this point!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center