Modfying a sentence

Discussion in 'PHP' started by darkhorn, Nov 15, 2008.

  1. #1
    I want to change some words to another, for example I want to change all "human" words to "animal"... How I will do that?
    <?php
    
    $sentence = "human, human, human... One problem with the term is that it implies that human advancement...";
    
    /* ... */
    
    print $modified; // It will show "animal, animal, animal... One problem with the term is that it implies that animal advancement..."
    
    ?>
    PHP:

     
    darkhorn, Nov 15, 2008 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    
    $sentence = "human, human, human... One problem with the term is that it implies that human advancement...";
    $modified = str_replace('human','animal',$sentence);
    print $modified;
    
    PHP:
     
    ads2help, Nov 15, 2008 IP
  3. darkhorn

    darkhorn Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hurray! Thanks :)
     
    darkhorn, Nov 15, 2008 IP