How to substitute a character for another one

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • francescomoi@europe.com

    How to substitute a character for another one

    Hi.

    I want to substitute a character (e.g. 'R') for another one ('-R')
    within a
    word: 'RECORD' ---> '-RECO-RD'

    Is it possible by using any PHP command? Regards.

  • nickeb@gmail.com

    #2
    Re: How to substitute a character for another one

    <?

    $i = "record";

    $x = str_replace("r" , "-r", $i); // looks through i for r's, replaces
    them with -r's

    echo $x;

    ?>

    that should work.

    Comment

    Working...