Shortening 2 str_replaces

Discussion in 'PHP' started by mahmood, Feb 3, 2008.

  1. #1
    I know there is a way to shorten these two lines into one but I couldn't get it working:
    
    $word = str_replace(",","",$word);
    $word = str_replace(":","",$word);
    
    PHP:
    Any idea?
     
    mahmood, Feb 3, 2008 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    $word = str_replace(array(',', ':'), '', $word);
    PHP:
     
    SoKickIt, Feb 3, 2008 IP
    mahmood likes this.
  3. pizzagreezi

    pizzagreezi Peon

    Messages:
    43
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can try preg_replace with regex too.
     
    pizzagreezi, Feb 3, 2008 IP
    mahmood likes this.