1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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.