Why doesn't my str_replace wildcard not work?

Discussion in 'PHP' started by mark_s, Apr 7, 2009.

  1. #1
    I'm trying to remove the contents of everything insides () brackets.

    <? $test = '(test)';
    $test = str_replace('("[^"]*")', 'test', $test);
    echo $test; ?>

    The above doesn't work, can someone help?
     
    mark_s, Apr 7, 2009 IP
  2. emed

    emed Peon

    Messages:
    70
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    emed, Apr 7, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    str_replace only replaces a string with a string.

    Try preg_replace() or ereg_replace() that uses regular expressions.

    - ads2help
     
    ads2help, Apr 7, 2009 IP