www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP 5.2 is treating negative numbers as strings

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Posts
    227

    PHP 5.2 is treating negative numbers as strings

    Hi!

    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
    Location
    Ankh-Morpork
    Posts
    19,536
    Any chance you're depending on the (optional) 5th parameter to fgetcsv()? It was added in 5.3.0.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2010
    Posts
    227
    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
    Posts
    227
    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



Recent Articles