Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    str_repalce (remove numbers 123)

    How do you replace numbers but not static, cause the numbers can change, so I need it to be able to replace any type of numbers?

    PHP Code:
    <?
    $test 
    "hello 123";
    $resplace_teststr_replace("[0-9]"""$test);
    echo 
    $test;
    ?>
    Thanks
    Last edited by sitNsmile; 04-02-2010 at 07:43 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Code:
    <?php
    $test = "hello 123";
    $resplace_test= preg_replace("/[0-9]/", "", $test);
    echo $resplace_test;
    ?>
    PS: Using short open tag is a bad practice.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by abduraooft View Post
    Code:
    <?php
    $test = "hello 123";
    $resplace_test= preg_replace("/[0-9]/", "", $test);
    echo $resplace_test;
    ?>
    PS: Using short open tag is a bad practice.
    I usually use the <?php but I was quickly just adding it for the forum.
    -Thanks that did work.


  •  

    Posting Permissions

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