我自己得到了这里需要更多的文字,因为只是在这里,所以这没有意义,但我自己解决了
function mw($text, $width)
{
$wrapped = wordwrap( $text, $width, "\n" );
$lines = explode( "\n", $wrapped );
foreach ( $lines as $line )
{
$leers = "";
$num_leers = $width - strlen( $line );
if ( $num_leers > 0 ) {
$leers = str_repeat ( " " , $num_leers );
}
echo "- $line$leers -<br>";
}
}
输出:
- ipsum dolor sit amet, consectetur adipiscing elit. -
- Nunc placerat, mauris et tempor pharetra, tellus -
- felis vestibulum tortor, at porta dui lectus -
- non ante. Maecenas fringilla, enim et elementum -
- dignissim, leo urna commodo magna, quis laoreet -
- nisl mi ut sapien. Proin porttitor pellentesque -
- lobortis. Morbi cursus tellus ornare magna -