Created
April 24, 2013 23:17
-
-
Save ricardoalcocer/5456391 to your computer and use it in GitHub Desktop.
PHP Script to add P Tags to plain text documents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<h1>"P-Tag It!"</h1> | |
<?php | |
function addParagraphs($text){ | |
// Add paragraph elements | |
$lf = chr(10); | |
return preg_replace('/ | |
\n | |
(.*) | |
\n | |
/Ux' , $lf.'<p>'.$lf.'$1'.$lf.'</p>'.$lf, $text); | |
} | |
if(isset($_POST["document"])){ | |
$doc=addParagraphs(PHP_EOL.$_POST["document"].PHP_EOL); | |
$doc=stripslashes($doc); | |
} | |
?> | |
<form action="index.php" method="POST"> | |
<div> | |
<textarea cols="100" rows="30" name="document" onClick="this.select();"> | |
<?php echo $doc ?> | |
</textarea> | |
</div> | |
<div style="margin-top: 20px"> | |
<input type="submit" value="P-Tag it!"/> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANKS BRO !