我只是想知道是否有人能幫助我。我一直試圖弄清楚這一點。 我有這些變量php函數將描述分成多行68個字符長
$booking['occasion']
$booking['date']
$booking['venue']
,我希望做一個描述出他們的這個樣子。 「
$ description =」在$場館中爲 $日期提供$場合DJ的存款「;
我想顯示在PDF文件中像這樣
$pdf->writeHTMLCell(139, 5, '20', '125', $line1, '', 1, 1, true, 'L', true);
$pdf->writeHTMLCell(139, 5, '25', '125', $line2, '', 1, 1, true, 'L', true);
$pdf->writeHTMLCell(139, 5, '30', '125', $line3, '', 1, 1, true, 'L', true);
$pdf->writeHTMLCell(139, 5, '35', '125', $line4, '', 1, 1, true, 'L', true);
$pdf->writeHTMLCell(139, 5, '40', '125', $line5, '', 1, 1, true, 'L', true);
我想每68個字符後以包裹描述到下一行超過3條或4線的描述,而是僅希望包裹完成之後詞語
任何人都可以幫助我創建一個功能,將desicprtion分成3或4行到目前爲止我知道這個代碼是我想要的。
$description = "Deposit for suppling a DJ and Equipment for a $occasion on the
$date in $venue";
$decriptionLength = strlen($description);
if($decriptionLength <= 68){
$line1 = $description;
}
elseif($decriptionLength > 68)
{
$line1 = substr($description, 0, 68);
$line2 = substr($description, 68, 136);
}
這段代碼將包裝文本,即使在一個詞的中間,所以我不想這個。 我知道這可能是很多要問,但如果任何人都可以想出一些代碼,我將不勝感激。
您是否嘗試過['換行()'](http://www.php.net/wordwrap)? –