Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split a text into two columns with PHP

Tags:

php

split

I would like to know if there is possible to split a text in two parts.

On my website I have a product description (500-1000 words) and I would like to display it like so:

<div class="text-col">
    <?php echo nl2br($col1); ?>
</div>


<div class="text-col">
    <?php echo nl2br($col2); ?>
</div>
like image 799
Psyche Avatar asked Apr 21 '12 14:04

Psyche


1 Answers

Something like this?

$len = strlen($input);
$space = strrpos($input," ",-$len/2);
$col1 = substr($input,0,$space);
$col2 = substr($input,$space);
// now output it
like image 116
Niet the Dark Absol Avatar answered Oct 05 '22 04:10

Niet the Dark Absol