str_replace question

Discussion in 'PHP' started by linkinpark2014, Aug 10, 2008.

  1. #1
    I have this str_replace regex:

    $username="any string in english letters";
    $convert = str_replace('(a-zA-Z)*?', "unknown", $username); 
    echo $convert;
    Code (markup):
    its suppose to b like this but when I run it gives me "any string in english letters" without any replacements it should outputs only "unknown" string...:rolleyes:

    any ideas?
     
    linkinpark2014, Aug 10, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    str_replace doesn't support RegEx. Use eregi_replace or preg_replace.

    Jay
     
    jayshah, Aug 10, 2008 IP
  3. linkinpark2014

    linkinpark2014 Peon

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ooops...little mistake

    anyway thanx a lot u saved ma a** :)
     
    linkinpark2014, Aug 10, 2008 IP