I'm aware that there are multiple examples of this within this forum and others, I've tried them all, but couldn't get either to work. I got a php-script that writes to a php-file, wich gets loaded within a php script.
My purpose is to get automatic br-tags into the php-post once people push 'enter'
<?php
if ( isset( $_POST[ 'submit' ] ) ) {
$com = $_POST['txt'];
If ($com === "") {
echo "<font color=red><b>You must write something to post!</font></b>";
die;
}
$time = gmdate("M d Y H:i:s",time()+(2*60*60));
$com = $_POST['txt'];
$count = strlen($com);
$com = stripslashes($com);
$breaks = array("<br />","<br>","<br/>");
$com = str_ireplace($breaks, "
", $com);
$fp = $file = fopen( "NAME_OF_POST.php", "a");
Multiple fwrites follows.....
Multiple fwrites follows.....
rewind($fp);
fclose($fp);
echo '<script type="text/javascript">window.location ="";</script>';
}
?>
and it loads within:
<textarea name="txt" id="area" class="typo_vind" placeholder="......" tabindex="1"></textarea>
Anyone knows how to get linebreaks from enter to be replaced with br-tags?
In advance, than you :)!
$breaks = array("
");
$com = str_ireplace($breaks, "<br />", $com);
Switching places did the trick :) Thank you all:)
Well, php has a function for that:
$yourString = "text
with
enters";
$result = nl2br( $yourString );
print $result
// output:
// text<br>with<br>enters
look at docs
OMG !!!!!!!
$breaks = array("
");
$com = str_ireplace($breaks, "<br />", $com);
After a lot of search this work well !!!!!!! ♥☻☻☻♥♥♥