Feeds:
Posts
Comments

Archive for the ‘Programming’ Category

VbCrLf di PHP

simple script untuk replace [new line – enter] menjadi <br> di PHP :

$tampil = preg_replace(‘/(\r\n|\n|\r|\f)/U’, “<br />”, $text);

example :

<?php

$t = $_POST[‘test’];

$tampil = preg_replace(‘/(\r\n|\n|\r|\f)/U’, “<br />”, $t);
echo ‘test : ‘. $tampil;

?>
<html>
<head>
<title>test</title>
</head>
<body>

<form name=”test” method=”post” action=”test.php”>
ini inputnya : <br>
<textarea name=”test” rows=”20″ cols=”80″></textarea><br>
<input type=”submit” value=”submit” name=”submit”><br><br><br>
</form>

ini hasilnya : <br>
<textarea name=”test2″ rows=”20″ cols=”80″><?=$tampil?></textarea><br>
</body>
</html>

Advertisements

Read Full Post »