wanna remove numbers from the output string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasadshete
    New Member
    • Feb 2007
    • 19

    wanna remove numbers from the output string

    hey guys ,plz help me out to remove numbers in the name of the out put string..
    i am new to PHP..i have to fetch the name from database. and in some name numbers and spaces are available and i wnat to remove them.plz help me out
  • basstradamus
    New Member
    • Mar 2007
    • 11

    #2
    Hi,
    You can use str_replace. It will replace any char that you want to on something else or on to "" which will remove unnecessary character.
    Have a look on http://us.php.net/str_replace . I am pretty shure that it will help you.

    Code:
    // Provides: Hll Wrld f PHP
    $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
    $onlyconsonants = str_replace($vowels, "", "Hello World of PHP");
    Basing on str_replace:
    Code:
    // 
    $vowels = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
    $onlyconsonants = str_replace($vowels, "", $stringThatHaveToBeClean);
    You can also use regular expresions but if you are newbie str_replace will be better.

    Comment

    • prasadshete
      New Member
      • Feb 2007
      • 19

      #3
      thamk you very much !!



      Originally posted by basstradamus
      Hi,
      You can use str_replace. It will replace any char that you want to on something else or on to "" which will remove unnecessary character.
      Have a look on http://us.php.net/str_replace . I am pretty shure that it will help you.

      Code:
      // Provides: Hll Wrld f PHP
      $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
      $onlyconsonants = str_replace($vowels, "", "Hello World of PHP");
      Basing on str_replace:
      Code:
      // 
      $vowels = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
      $onlyconsonants = str_replace($vowels, "", $stringThatHaveToBeClean);
      You can also use regular expresions but if you are newbie str_replace will be better.

      Comment

      Working...