Hi, I've been dealing withs this question: I've never seen dynamical balanced text in two colums in a web so this the challenge.
html formated text is stored in a database, conetion and placed into a variable i.e.: $text = "<P><IMG alt="labordeta" hspace=3 src="http://www.lamundial.net/img/labordeta.jpg" align=left border=0><EM>efe.Zaragoza.</EM> El parlamentario.</P><P>Some more text tranquilo simplenente trabajando.</P>"; ... some more paragrphs just like newspaper articles. the first idea is this: 1. count the total characters in $text string so we can guess juts the half 2. getting into $tx1 variable the fisrt half 3. count the total characters in $tx1 till the fisrt "</p>" STARTING from the END to the BEGUINING of $tx1 4. getting into $col1 the fist part 5. getting into $col2 the rest 6. render the text in a table //CODE 1. $half = floor(strlen($texto)/2); 2. $tx1 = substr($text,0,$half); 3. $first_P = strrpos($tx1,"</P>"); 4. $col1 = substr($text,0,$first_P); 5. $col2 = substr($text,$first_P); 6. <table> <tr> <td><?= $col1 ?></td> <td><?= $col2 ?></td> </tr> </table> PROBLEMS easy to know the middle point of a string but we have html code so easy to break it badly, something like: <IMG hspace=3 src="ht <-|-> tp://www.lamundial.net/img/img.jpg"> so this is why the </p> idea. If there is a large paragrph in the middle of the whole text the columns the two columns are not so nice balanced, this is why I ask the people writing articles for my web trying to avoid looooong ones. They use HTMLAREA http://www.interactivetools.com/products/htmlarea/ from Interactive tools so the html is not done by hand. anyway just in case there is no way to correctly balance the text I let the writer the "1 colum / 2 colums" as an option so the traditional 1 colum (no colums) is always available. they can display the final render os the article as they save it when writing so the decide. this is working at most of the articles in http://www.lamundial.net i.e.: http://www.lamundial.net/home.php?pg=article&idart=124 http://www.lamundial.net/home.php?pg=article&idart=121 http://www.lamundial.net/home.php?pg=article&idart=118 the text balancing is working quite nice any other idea? thanks aniceto lópez DYNAMICAL.BIZ web development host services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php