Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created April 24, 2013 23:17
Show Gist options
  • Save ricardoalcocer/5456391 to your computer and use it in GitHub Desktop.
Save ricardoalcocer/5456391 to your computer and use it in GitHub Desktop.
PHP Script to add P Tags to plain text documents
<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>
@franqross
Copy link

THANKS BRO !

@michaelminarcz
Copy link

Thanks for quick solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment