Results 1 to 3 of 3

Thread: Replacing text with text

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Replacing text with text

    Hi I am wanting to change | to <br/> but i don't know how I am including a txt file into a php script and i want it to change the | into a <br/>. I was wondering if any one would know how.

    Code:
    $files = include("modules/mod_oneononechat/chatfiles/$me.txt");
    
    
    $snr = new str_replace( "|", '<br/>', $files) ;
    
    $snr -> doSearch() ;
    The web in one word.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    It's just this:
    PHP Code:
    $snr str_replace"|"'<br/>'$files); 
    No need for the new command. You also can't include something in a variable, so:
    Code:
    $files = file_get_contents("modules/mod_oneononechat/chatfiles/$me.txt");
    Use file_get_contents instead.
    Jeremy | jfein.net

  3. #3
    Join Date
    Apr 2009
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hai try this so simple
    <?php
    $file=fopen("aa.txt","r");
    while(! feof($file))
    {
    $tt= fgets($file). "<br />";
    echo str_replace("|","<br>",$tt);
    }
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •