我試圖如下采取一個輸入字符串:意外結果用PHP函數格式字符串
示例輸入
<p>
In spite of how delightfully smooth the full-grain leather may be,
it still provides quite a bit of durability to the upper of this
Crush by Durango women's Western boot. Everything about this
pull-on boot is stunning; you have the floral embroidery, the pop
of metallic and a stylish x toe. To make these 12” floral
boots ease to get on, Durango added two very sturdy pull straps
next to the boot’s opening.</p>
<ul>
<li>
2 1/4" heel</li>
<li>
Composition rubber outsole with vintage finish</li>
<li>
Cushion Flex insole</li>
</ul>
併產生以下輸出:
輸出字符串
In spite of how delightfully smooth the full-grain leather may be,
it still provides quite a bit of durability to the upper of this Crush by
Durango women's Western boot. Everything about this pull-on boot is stunning;
you have the floral embroidery, the pop of metallic and a stylish x toe.
To make these 12」 floral boots ease to get on, Durango added two very sturdy
pull straps next to the boot’s opening.
2 1/4" heel
Composition rubber outsole with vintage finish
Cushion Flex insole
我有以下功能:
功能
function cleanString($str)
{
$content = '';
foreach(preg_split("/((\r?\n)|(\r\n?))/", strip_tags(trim($str))) as $line) {
$content .= " " . trim($line) . PHP_EOL;
}
return $content;
}
在這個函數返回In spite of how delightfully smooth the full-grain leather may be
和修剪字符串的其餘部分的時刻。
有誰請解釋如何改變以產生上述的輸出功能?
需要刪除標籤嗎? – 2014-09-26 11:38:36
@RakeshSharma - 刪除任何HTML標籤和縮進。謝謝 – aphextwix 2014-09-26 11:41:33