Log in

View Full Version : Replacing text with text



queerfm
04-17-2009, 12:03 PM
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.



$files = include("modules/mod_oneononechat/chatfiles/$me.txt");


$snr = new str_replace( "|", '<br/>', $files) ;

$snr -> doSearch() ;

Nile
04-17-2009, 08:00 PM
It's just this:


$snr = str_replace( "|", '<br/>', $files);


No need for the new command. You also can't include something in a variable, so:


$files = file_get_contents("modules/mod_oneononechat/chatfiles/$me.txt");

Use file_get_contents instead.

ganu
04-20-2009, 07:29 AM
Hai try this so simple
<?php
$file=fopen("aa.txt","r");
while(! feof($file))
{
$tt= fgets($file). "<br />";
echo str_replace("|","<br>",$tt);
}
?>