とでデータを適切に表示するHTMLのチャンクを考えると<div>
、<table>
個々のセルとdivで元々見つかったテキストを改行だけで区切ったまま、すべてのHTML /CSSマークアップを削除するにはどうすればよいでしょうか。
ここに示されている現在の試みでは、divまたはtable形式の場合、分離を維持する代わりに、1つの長い連続した段落が出力されます。
元のHTML: http: //pastebin.com/63N3Kg16
出力:
John Smith | SomeName Realty | (xxx) 939-4835 Allston St, Cambridge, MA Very spacious under renovation with SST/Granite, porch, minutes to MIT, redline, Nov/1 4BR/1BA Apartment $3,400/month Bedrooms 4 Bathrooms 1 full, 0 partial Sq Footage Unspecified Parking None Pet Policy No pets Deposit $0 DESCRIPTION Triple decker building secondfloor apt aprox 2000 sqf with large bedrooms, kitchen, pantry, porch, d/w, all woodfloor and ZTilded in the kitchen, new bath. utilities extra,Nov/1 see additional photos below Contact info: Payman Ahmadifar Bayside Realty (xxx) 939-4835 Posted: Sep 24, 2012, 6:55am PDT
PHP
nl2br(trim(strip_tags($html)));
期待される出力
<br>
または改行、no<div>
または<table>
HTMLマークアップのいずれかを含むプレーンテキスト。基本的に、テキストを読みやすくするために、元のテキストの間隔/分離構造を維持しますが、を除いてCSSスタイルやHTMLマークアップは使用しません<br>
。
John Smith | SomeName Realty | (xxx) 939-4835
Allston St, Cambridge, MA
Very spacious under renovation with SST/Granite, porch, minutes to MIT, redline, Nov/1
4BR/1BA Apartment $3,400/month
Bedrooms 4
Bathrooms 1 full, 0 partial
Sq Footage Unspecified
Parking None
Pet Policy No pets
Deposit $0
DESCRIPTION
Triple decker building secondfloor apt aprox 2000 sqf with large bedrooms, kitchen, pantry, porch, d/w, all woodfloor and ZTilded in the kitchen, new bath. utilities extra,Nov/1 see additional photos below
Contact info: Payman Ahmadifar Bayside Realty (xxx) 939-4835
Posted: Sep 24, 2012, 6:55am PDT