• 10Nov

    Replacing text with str_replace()
    We can replace text in PHP by using a function known as str_replace. We use it by putting in
    (“what we want to replace”, “with what we want to replace it with, and the”, $source); that it comes from.

    You need flash to play this tutorial.
    This tutorial goes over the following goals:
    Exploding, Imploding Arrays
    Replacing text
    You can find this tutorial video on youtube here.

    Here are the sources used in this tutorial:
    tut006.php
    <?php
    $sent = "The hog went to wash its face. Also, the hog went and rolled around in the mud...";
    //echo strlen($sent);
    
    /*$sents = explode(".",$sent);
    $se = implode("!",$sents);
    echo $se;*/
    $sent = str_replace(".","!",$sent);
    
    echo $sent;
    ?>

    Here are all the php functions used in this tutorial:

    Posted by Kloplop321 @ 4:52 pm

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.