添加换行符(php)并不像最初预期的那样工作

添加换行符(php)并不像最初预期的那样工作,php,html,line-breaks,Php,Html,Line Breaks,我一直在尝试使用以下代码在产品标题超过60个字符时添加换行符: if ($item->getProductType() == 'bundle') { foreach ($item->getChildren() as $child) { $childProduct = $this->productRepositoryInterface->getById( $child->getProduc

我一直在尝试使用以下代码在产品标题超过60个字符时添加换行符:

    if ($item->getProductType() == 'bundle') {
        foreach ($item->getChildren() as $child) {
            $childProduct = $this->productRepositoryInterface->getById(
                $child->getProductId(),
                false,
                $quote->getStoreId()
            );
            $childName = $childProduct->getName();
            $bundleText[] = $childName;
        }
        $line[] = [
            'text' => wordwrap($childName,60,"<br>\n"),
            'feed' => $feed + 10,
            'isProductLine' => true,
            'addToTop' => 5,
            'font' => 'regular',
            'font_size' => $fontSize
        ];
    }

    $optionLineCount = 0;
    if (isset($optionText)) {
        $optionLineCount += count($optionText);
    }

    if (isset($bundleText)) {
        $optionLineCount += count($bundleText);
    } 

你知道我还缺少什么吗?

你在哪里查看了你的输出?@slier输出是在pdf文档中生成的(Magento 2.3.3;扩展Cart2Quote pdf模块的自定义模块)

在pdf中不起作用。我很确定你需要使用
“\n”
@Jullian显然Pdf不明白

标签是什么,也许你在寻找
\r
你可以试试
\r\n
如果没有,那么
\r
或者
\n
如果仍然不起作用。。只需删除

RSM-408A: 8-Port Real-time Redundant Ring Switch with metal<br> case (+12 ~ +48 VDC, non-isolation)
RSM-408A: 8-Port Real-time Redundant Ring Switch with metal
case (+12 ~ +48 VDC, non-isolation)