Split text into 2 paragraphs


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?
  2. $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris. Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Proin quis tortor orci. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet.';
  3. $words = explode(" ",$text); $cntWords = count($words); $splitWords = round($cntWords/2);
  4. ?>
  5. <div class="text">
  6. <p class="l"><? for ($i=0;$i<=$splitWords;$i++) print $words[$i].' '; $halfPoint = $i; ?></p>
  7. <p class="r"><? for ($i=$halfPoint;$i<=$cntWords;$i++) print $words[$i].' '; ?></p>
  8. </div>

URL: http://pcvst.urbanedgeny.com/availabilities

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.