Skip to content

Instantly share code, notes, and snippets.

@sole
Created August 19, 2011 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sole/1156911 to your computer and use it in GitHub Desktop.
Save sole/1156911 to your computer and use it in GitHub Desktop.
Testing double spaces
<?php
$txt = '';
$pasted_text = '';
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$pasted_text = $_POST['text'];
$text = str_replace("\n", '<span class="n"></span>' . "\n", $pasted_text);
$text = str_replace("\r", '<span class="r"></span>' . "\r", $text);
$txt = 'You pasted this:<br /><pre>' . $text . '</pre><br />(end of your paste)';
}
?><!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<?php echo $txt; ?>
<form action="" method="post">
<textarea name="text" placeholder="PASTE SOMETHING HERE, press submit" rows="20" cols="80"><?php echo $pasted_text; ?></textarea><br />
<input type="submit" value="submit" />
</form>
<style>
pre {
background: #eee;
font-family: Monaco,"Andale Mono","Bitstream Mono",Courier,terminal;
font-size: 12px;
height: auto;
line-height: 1;
padding: 10px;
width: auto;
max-width: 99%;
}
.n {
padding: 0 10px;
background: #f00;
}
.r {
padding: 0 10px;
background: #0f0;
}
</style>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment