in a
This is a simple question; I will make it simple.
So, I have a <textarea name="textarea"> in a <form method="POST">
<textarea name="textarea"> in a <form method="POST">
<?php $textarea = $_POST['textarea']; echo nl2br($textarea);
Decides to keep the NEW LINES,
But how can I support TABS?
tab2tab () or something?
Although not intended for this specific use, you can:
$textarea = str_replace("\t", " ", $_POST['textarea']);
Or if you need the equivalent of HTML space:
$textarea = str_replace("\t", " ", $_POST['textarea']);
You don’t need to at all nl2br, it is more a problem of how you tell the browser what to do with all these spaces:
nl2br
echo "<pre>", htmlspecialchars($textarea), "</pre>";
and what is he. See the <pre>HTML Docs tag , which also reports white-spaceCSS Docs , if you're interested.
<pre>
white-space
4 <pre></pre>.
<pre></pre>