如何使用laravel 5在pdf生成的地址栏中显示逗号所在的新行?

时间:2015-09-29 07:47:49

标签: php laravel-5 html2pdf

我正在尝试在新行中显示地址,其中逗号就像我的地址一样

#23, "Hari Prem Building", 1st Floor, Off CMH Road, Indiranagar, Bangalore, India

我只想将我的地址显示为

#23,
"Hari Prem Building",
1st Floor,
Off CMH Road,
Indiranagar,
Bangalore,India

为此,我尝试了像{!! nl2br(e($inv->Address)) !!}这样的laravel语法,但它不适用于我? 请帮我解决这个问题.. 感谢。

1 个答案:

答案 0 :(得分:0)

我不知道pdf如何读取换行符,因此您必须相应地调整换行符,但执行此操作的简单方法是:

$string = '#23, "Hari Prem Building", 1st Floor, Off CMH Road, Indiranagar, Bangalore, India';

$array = explode(',',$string);
echo implode(',' . PHP_EOL ,$array);

然后您只需要用适当的换行符替换PHP_EOL。像这样:

echo implode(', \n' ,$array); //with \n
echo implode(', <br />' ,$array); //With <br />