Forum Moderators: coopster
How do I stop this from happening? Below are pieces of the code I am using.
Save Code:
<?php
$news_date = date("l n/d/y - g:i A");
$news_file = ("news.txt");
$fp = fopen($news_file, "a+");
fputs ($fp, "form data goes here\n");
fclose($fp);
echo "<script>location.href='preview.php'</script>";
?>
Load, Reverse, Display Code:
<?php
$data = file('news.txt');
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("¦", $element);
echo $pieces[2] . $pieces[1] . "" . $pieces[0] . "";
}
?>
Any help will be greatly appreciated.
I simply use the PHP string replace to remove all instances of \' in the data, just before it is displayed (echo) in the HTML. Like I said, this is only a temporary solution, and I still need some help actually saving the data to the text file without any instances of \' being in it.
PHP String Replace Code:
<?php
$data = file('news.txt');
$data = str_replace("\'", "'", $data);
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("¦", $element);
echo $pieces[2] . $pieces[1] . "" . $pieces[0] . "";
}
?>
Again, any help will be greatly appreciated.