Jump to content

keep format's with strings


kevdotbadger

Recommended Posts

Hello, im writing a simple script which html is entered into a form, the ata is prcessed and it returns the formatted code, with htmlentries removed and replaced with there text equvilent.

<html>
<head>
<title>Upload</title>
</head>
<body>
<?php

$posttext = $_POST['code'];

$posttext_remove_crap = htmlspecialchars($posttext);

if(isset($posttext)){
echo "<div style='padding: 10px; border: 1px solid black; display: block; width: 900px;'>";
echo $posttext_remove_crap;
echo "</div>";
};
?>

<form action="convert.php" method="POST">
<textarea name="code" rows="100" cols="100"></textarea>
<input type="submit" value="Go">
</body>
</html>


so far the html removal works. But its all returned in one line and the format is gone (white space, paragraph space etc)

how would i go about keeping the format when the string is echoed?
Link to comment
https://forums.phpfreaks.com/topic/25971-keep-formats-with-strings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.