Jag hittade ett exempel tror jag:
<?php /*________________________________________________________________
lixlpixel PHParadise
_______________________________________________________________________
category : string handling
snippet : string to columns
downloaded : 04.22.2008 - 07:02
file URL : http://www.fundisom.com/phparadise/php/string_handling/string_to_columns
description : this will "columnize" your long text.
long text, especially on large screens is really hard to read.
thats why in the "real world" newspapers use columns to layout text.
with this script you just paste the text and specify the numbers of columns.
it will split the text into more reader-friendly chunks.
___________________________START___COPYING___HERE__________________*/ ?>
<?php
$marginpercent = 3;
$topmarginpx = 200;
$bgcolor = 'whitesmoke';
$paddingpx = 5;
$seperators = array(' ' => 'words', '. ' => 'sentences', '<p>' => 'paragraphs');
if($_POST['string'])
{
if($_POST['column']) $columns = $_POST['column'];
else $columns = 3;
if($_POST['seperator']) $seperator = $_POST['seperator'];
else $seperator = ' ';
$widthpercent = ceil(((100-(2*$marginpercent))/$columns)-2);
$stringlen = strlen($_POST['string']);
$percolumn = ceil($stringlen/$columns);
for($x = 0; $x < $columns; $x++)
{
$leftpx = (($x*ceil((100-(2*$marginpercent))/$columns))+$marginpercent);
$string = stripcslashes(substr($_POST['string'],($percolumn*$x),$percolumn));
$nextstring = stripcslashes(substr($_POST['string'],($percolumn*($x+1)),$percolumn));
$nextpos = strpos(strtolower($nextstring),strtolower($seperator));
$nextword = substr($nextstring,0,($nextpos+strlen($seperator)));
$string = substr($string,$oldpos,$percolumn);
$string = $string.$nextword;
$oldpos = $nextpos+strlen($seperator);
echo '
<div style="position:absolute;
left:'.$leftpx.'%;
top:'.$topmarginpx.'px;
padding:'.$paddingpx.'px;
width:'.$widthpercent.'%;
background-color:'.$bgcolor.';">
';
if($x > 0 && $_POST['heightpx']) echo '
<div style="height:'.$_POST['heightpx'].'px; width:'.$widthpercent.'%;"> </div>';
echo $string;
echo '
</div>
';
}
}else{
echo '
<div style="position:absolute;
left:'.$marginpercent.'%;
top:'.$topmarginpx.'px;
padding:'.$paddingpx.'px;
width:'.(100-(2*$marginpercent)).'%;
background-color:'.$bgcolor.';">
<form method="post" action="'.$_SERVER['PHP_SELF'].'">
<textarea name="string" cols="70" rows="20"></textarea><br />
<input type="text" name="column" value="3" size="3" /> columns | text split at
<input type="text" name="seperator" size="3" />
<select name="preset" onchange="seperator.value=this.value">';
foreach($seperators as $k => $v)
{
echo '
<option value="'.$k.'">'.$v.'</option>';
}
echo '
</select> |
<input type="text" name="heightpx" value="" size="3" /> topmargin on column 1+ |
<input type="submit" value="columnize" />
</form>
</div>
';
}
?>
<?php /*_____________________END___OF___THE___CODE______________________
get more code from http://www.fundisom.com/phparadise/
___________________________________________________________________*/ ?>