I try to copy and paste TAB delimited list into html text area, then save it to database, however when I retrieve it from DB, all TAB space are gone, does anyone can give me advice is there a way to keep these TAB?
Thanks in advance.

test     test     test                       <----regular space
==============
test	test	test                            <----one TAB space
test		test		test            <----two TAB spaces

when I retrieve from DB, it shows:

test test test
==============
test test test
test test test

P.S. The DB field is TEXT datatype (I use MSSQL)

you could try:

str_replace("	", "\t" $string);
commented: Hmm.. Right.. +7

You can also use <pre> tag.
http://www.w3schools.com/TAGS/tag_pre.asp

<?php
mysql_connect("localhost","root");
mysql_select_db("test");
if(isset($_POST['submit'])) {
	mysql_query("insert into tst (name) values ('".$_POST['tarea']."')");
}
?>
<html>
<body>
<form method="post">
<textarea name="tarea" cols="30" rows="20"></textarea>
<input type='submit' name="submit" value="submit">
</form>
</body>
</html>
<?php
$q = "select * from tst";
$r = mysql_query($q);
if(mysql_num_rows($r) > 0 ) {
while($row = mysql_fetch_array($r)) {
	echo "<pre>";
	echo $row['name'];
	echo "</pre>";
	echo "<br>";
}
}
?>

Just did a quick check to see if it works and it does..

you could try:

str_replace("	", "\t",$string);

I think that doesn't work.. :-/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.