Code: Select all
$myFile = "chatFile.txt";
$whitespaceS = " shouts: ";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "$displayname$whitespaceS $ShoutInput $whitespaces";
fwrite($fh, $stringData);
fclose($fh);Code: Select all
<?php
$file = fopen("chatFile.txt","r");
$savedfile = fopen("chatFile.txt", "r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>and lets assume stringdata = Hi my name's bob
the output on my chatserver is, Hi my name\'s bob
Code: Select all
if($stringdata)
{
$string = $stringdata;
$pattern = "/\'/";
$replacement = "'";
$stringdata = preg_replace($pattern, $replacement, $string);
}the problem is when someone's chat contains an ' it replaces it with \' so I'm trying to search the string for \' before its wrote to file and replace it with ' like it should be, what is the correct pattern?? I know this sounds newbie but i can't find a list of pattern modifiers, I'm forced to ask you.