#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    How can I find out how many decimal places are in a string? If there is more than one decimal place then I want to reject the input.
  2. #2
  3. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if(preg_match("/.d{1}/", $variableName))
    {
    // pass, do something
    }
    else
    {
    // fail, reject input
    }[/code]

    i haven't test the code above, so just let me know if it doesn't work and i'll make it work :-)

    [This message has been edited by RyanP (edited August 12, 2000).]

Similar Threads

  1. Specifying number of decimal places for output
    By CodE-E in forum PHP Development
    Replies: 6
    Last Post: March 4th, 2004, 12:28 PM
  2. Replies: 0
    Last Post: November 12th, 2003, 10:20 AM
  3. Web form field decimal places
    By jwpearson in forum HTML Programming
    Replies: 3
    Last Post: November 11th, 2003, 05:06 PM
  4. Variable number of decimal places
    By pozter in forum PHP Development
    Replies: 14
    Last Post: May 3rd, 2003, 12:26 AM
  5. No. of decimal places for float type
    By OB_redemption in forum Perl Programming
    Replies: 3
    Last Post: October 5th, 2002, 01:55 AM

IMN logo majestic logo threadwatch logo seochat tools logo