1 2 3 4 5 6
<?php $str= 'This is some example text , I want to print this variable in 3 lines, also.'; $x = '12'; $array = explode( "\n", wordwrap( $str, $x)); var_dump($array); ?>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
array(7) { [0]=> string(12) "This is some" [1]=> string(12) "example text" [2]=> string(11) ", I want to" [3]=> string(10) "print this" [4]=> string(11) "variable in" [5]=> string(8) "3 lines," [6]=> string(5) "also." }