Lorem Ipsum Generator
This form provides a convenient means of generating Lorem Ipsum text, marked up with HTML paragraph, list item, or division tags; and word-wrapped so that it can conveniently be copy-and-pasted into any text editor. For more info on why graphic designers use this text, see the "Lorem Ipsum" article at wikipedia.org.
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Source Code
<?php
$sentences = array(1 =>
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
);
$nbr = (isset($_GET['nbr']) and
in_array($_GET['nbr'], range(1,10))) ?
$_GET['nbr'] : 1;
$elem = (isset($_GET['elem']) and
in_array($_GET['elem'], array('p', 'li', 'div'))) ?
$_GET['elem'] : 'p';
$sent = (isset($_GET['sent']) and
in_array($_GET['sent'], range(1,10))) ?
$_GET['sent'] : 1;
?>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get'>
<fieldset>
<legend>Lorem Ipsum Generator</legend>
<p>
<label>HTML element type:
<select name='elem'>
<?php
$elements = array(
'p' => 'paragraph',
'li' => 'list item',
'div' => 'div'
);
foreach($elements as $key => $val)
{
echo "<option value='$key'";
if(isset($_GET['elem']) and $_GET['elem'] == $key)
{
echo " selected='selected'";
}
echo ">$val</option>\n";
}
?>
</select>
</label>
</p>
<p>
<label>Number of elements:
<select name='nbr'>
<?php
for($ix = 1; $ix <= 10; $ix++)
{
echo "<option value='$ix'";
if(isset($_GET['nbr']) and $_GET['nbr'] == $ix)
{
echo " selected='selected'";
}
echo ">$ix</option>\n";
}
?>
</select>
</label>
</p>
<p>
<label>Number of sentences per element:
<select name='sent'>
<?php for($ix = 1; $ix <= 10; $ix++)
{
echo "<option value='$ix'";
if(isset($_GET['sent']) and $_GET['sent'] == $ix)
{
echo " selected='selected'";
}
echo ">$ix</option>\n";
}
?>
</select>
</label>
</p>
<p><input type='submit' value='Get Lorem Ipsum text'></p>
</fieldset>
</form>
<pre id='copytext'>
<?php
$count = 1;
$text = array();
for($i = 1; $i <= $nbr; $i++)
{
$text[$i] = "<$elem>";
for($j = 1; $j <= $sent; $j++)
{
$text[$i] .= $sentences[$count].' ';
if(++$count > 4) { $count = 1; }
}
$text[$i] = trim($text[$i])."</$elem>";
$text[$i] = wordwrap($text[$i]);
}
echo htmlspecialchars(implode("\n", $text));
?>
</pre>