SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2000
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a client that wants a shopping cart developed and he has an unusual request.
    His cart will be used to purchase custom signs online and he charges by the amount of letters in the message of the sign.

    My question is: Is there a way to "count" the amount of characters that someone has typed into a form textbox?
    If there is a way, an example would be greatly appreciated.

    Thank you

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, This should do this trick:

    PHP Code:
    <?

    $var 
    "Do What?";

    $lenth strlen($var);

    print 
    $lenth;

    ?>
    Peter

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is " " (space) free?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd assume it would be on total length and not just the number of characters. But if space ' ' is "free" then you'd want to remove them:
    PHP Code:
    <?PHP

    $var 
    "Do What?";

    $lenth strlenstr_replace""" "$var ) );

    print 
    $lenth;

    ?>

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Slightly wrong there matt:

    PHP Code:
    <?PHP

    $var 
    "Do What?";

    $length strlen(str_replace" """$var ));

    print 
    $length;

    ?>
    Peter

  6. #6
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My bad!


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
  •