下午,
美丽的天气不是吗?好吧反正..
这是我的问题:(见照片)http://prntscr.com/7drmc5
当然这不是非常用户友好的,我试图只显示该字段的前100个字符,休息一下。
这是我的代码:
echo '<tbody>
<tr class="server glossed site">
<td class="rank hidden-sm hidden-xs">
'.$rank.'</td>
<td class="description"><p><a href="out.php?id='.$row['id'].'" target="_blank">'.$row['name'].'<br /><p><a href="out.php?id='.$row['id'].'" target="_blank"><img src="'.$row['banner'].'" width="470" height="60"></a></p></a><br><p class="hidden-sm hidden-xs">'.
$row['description'].'</p></td>
<td class="votes hidden-sm hidden-xs">'.$row['votes'].'</td>
</tr>
';
感谢任何给出这个镜头的人!
答案 0 :(得分:0)
//it would wrap your text upto 20 characters
$wrappedText = wordwrap(substr($row['description'], 0, 100), 20, "<br />\n", true);
echo '<tbody>
<tr class="server glossed site">
<td class="rank hidden-sm hidden-xs">
'.$rank.'</td>
<td class="description"><p><a href="out.php?id='.$row['id'].'" target="_blank">'.$row['name'].'<br /><p><a href="out.php?id='.$row['id'].'" target="_blank"><img src="'.$row['banner'].'" width="470" height="60"></a></p></a><br><p class="hidden-sm hidden-xs">'.
$wrappedText.'</p></td>
<td class="votes hidden-sm hidden-xs">'.$row['votes'].'</td>
</tr>
';
答案 1 :(得分:0)
使用substr();
$result = substr($myStr, 0, 100);//it will dispaly to firdt 100 charector from string
在代码中,它将实现为
<td class="description"><p><a href="out.php?id='.$row['id'].'" target="_blank">'.$row['name'].'<br /><p><a href="out.php?id='.$row['id'].'" target="_blank"><img src="'.$row['banner'].'" width="470" height="60"></a></p></a><br><p class="hidden-sm hidden-xs">'.
substr($row['description'],0,100).'</p></td>
根据您的情况使用
wordwrap($row['description'], 100, "\n", true);