Why does "var_dump" give me different data than "echo"?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luftikus143
    New Member
    • Jan 2007
    • 97

    Why does "var_dump" give me different data than "echo"?

    Hi there,

    I am putting some decimal data from a database into an array, in order to draw a graph. This works generally without problem. But from time to time, the graph doesn't display correctly.

    Now, while echoing the data I get this:
    Code:
    43.2
    45.2
    49.6
    56.2
    65.1
    70.2
    50.5
    38
    36.6
    14.3
    15.2
    6.6
    4.1
    5.4

    Strange thing is that if I use a var_dump, I get this that is no more decimal data, but only integers:
    Code:
    array(1) { [0]=> array(14) { [0]=> string(2) "43" [1]=> string(2) "45" [2]=> string(2) "50" [3]=> string(2) "56" [4]=> string(2) "65" [5]=> string(2) "70" [6]=> string(2) "50" [7]=> string(2) "38" [8]=> string(2) "37" [9]=> string(2) "14" [10]=> string(2) "15" [11]=> string(1) "7" [12]=> string(1) "4" [13]=> string(1) "5" } }

    I checked with other decimal data, and there the var_dump output is correct:
    Code:
    [0]=> string(10) "0.00004316"
    that is, giving me the numbers behind the point too.

    What can be the reason for this?

    Thanks for any hints!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    the reason depends on your data processing, as I don’t know that, I can’t really tell something.

    PS. your data ain’t integers, they’re strings. generally, any data sent to the browser are strings.

    Comment

    • luftikus143
      New Member
      • Jan 2007
      • 97

      #3
      Thanks a lot. Got me thinking (into a different direction before) and trying out some stuff, and finding the (formatting) error indeed before that step.

      Comment

      Working...