SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2001
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Turn values inside varchar into doubles...

    I have a bunch of numbers inside varchar that I want to compare. However, as I understand, you cannot do a raw comparsion b/c the values are not exactly true numbers. Is there a function that turns the values inside varchar into doubles or integer so I can proceed with the comparsion?

    Thanks.

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    erm, i'm assuming by valchar you mean a string... i think you could use the intval() and doubleval() functions...

    also, you could simply type-cast the string variables to int/doubles... oftentimes PHP is smart enough to get the numerical values in the string...

    PHP Code:
    $int_value=intval($valchar10);  // 10 is the radix of the integer you want

    //or you can also do type-casting
    $double_value=(double)$valchar

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2001
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I got this to work now.


Bookmarks

Posting Permissions

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