Replace Special Character/Number In A Word

Discussion in 'PHP' started by simmer1974, May 12, 2010.

  1. #1
    Hello,

    How can i replace special characters that is from a array in a word.
    I want to control the special character that will be replaced.

    Example:
    Th1s is a ex@mpl3 @ #1
    to
    This is a example @ #1

    Thanks for your help.

    Simmer
     
    simmer1974, May 12, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    str_replace would do.
    $some_str = str_replace( array('1','@','3'), array('i','a','e'), $some_str);
     
    gapz101, May 12, 2010 IP
  3. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Here $some_str is a variable
    Exact one :)
     
    roopajyothi, May 12, 2010 IP
  4. simmer1974

    simmer1974 Member

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #4
    This changes also a 1 t=> i when it's not in a word.

    Wrong:
    Th1s i$ p@rt 1

    Correct:
    This is part 1
     
    simmer1974, May 12, 2010 IP
  5. mukunthan

    mukunthan Active Member

    Messages:
    237
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    mukunthan, May 12, 2010 IP
  6. simmer1974

    simmer1974 Member

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #6
    Regular expressions don't make any sence to me, php beginner here.
     
    simmer1974, May 12, 2010 IP
  7. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #7
    okay, it's a long process but it should work like:
    you also need a rule for an email if needed :D
     
    gapz101, May 12, 2010 IP