我使用的是文字包装函数php,但我希望逐行对齐。这是我的简单代码:
<?php
$text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software.';
$pish = wordwrap($text, 60, '|', 1);
$psh =explode('|',$pish);
echo $psh[0]."<br>";
echo $psh[1]."<br>";
for($i=2;$i<10;++$i){
echo $psh[$i]."<br>";
}
?>结果kode:
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industrys
standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a
type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing
software.如何证明这一点是合理的?
我想要结果:
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industrys
standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a
type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing
software.发布于 2015-03-27 11:56:17
您可以使用css对其进行归档。如果使用css对你来说没问题,那就试试下面的代码。希望这能对你有所帮助。
CSS
<style>
.fulljustify {
text-align: justify;
width:408px;
}
.fulljustify:after {
content: "";
display: inline-block;
width: 100%;
}
</style>php代码
<?php
$text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software.';
$pish = wordwrap($text, 60, '|', 1);
$psh =explode('|',$pish);
echo "<div class='fulljustify'>";
echo $psh[0]."</div>";
echo "<div class='fulljustify'>".$psh[1]."</div>";
for($i=2;$i<10;++$i){
echo "<div class='fulljustify'>".$psh[$i]."</div>";
}
?>https://stackoverflow.com/questions/29292756
复制相似问题