Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Thanked 0 Times in 0 Posts

    How to remove data from a variable before passing on

    I have a form on my site that goes like this:

    For Field, user enters EITHER 1tt or 1

    I want my php to check if they have entered 1tt or 1 and if tt is present remove the tt before proceeding and if tt exists then remove tt but keep the first number that they entered.

    The additional letter will always be the same so I do not need to check a-z, just tt. I know how to check for it, would just like to know how to split the variable / remove the letters from it.

    Any ideas?
    Last edited by Sussex_Chris; 04-30-2009 at 12:36 AM.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Thanked 14 Times in 14 Posts
    Something like this I suppose?

    PHP Code:
    $stringtt "1tt";

    stripos($stringtt'tt')){  // uses stripos since it case-insensitive for tt or TT
    echo 'tt found, should we abort? <br/>';
    //replace tt with ""
    $new_string str_ireplace("tt"""$stringtt);
    'The new string is: ' $new_string;


    Posting Permissions

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