/    Sign up×
Community /Pin to ProfileBookmark

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!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 08.2012 — Any chance you're depending on the (optional) 5th parameter to fgetcsv()? It was added in 5.3.0.
Copy linkTweet thisAlerts:
@BelrickauthorNov 08.2012 — 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!
Copy linkTweet thisAlerts:
@BelrickauthorNov 08.2012 — Definately the "" which is causing the grief with 5.2

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

Success!

Help @Belrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...