0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WYSIWYGエディタで書いたHTMLをメール送信する時のタグ除去と実体参照文字変換

Posted at

WYSIWYGエディタで書いたHTMLをメールでも内容を通知することがあったので、strip_tagsでタグだけ除去してたら、実体参照文字がまざったまま送信されちゃってました。

これも変換するなら次のようなコードを。

$before = '<p>Test&nbsp;Foo</p>'; // これを "Test Foo" にしたい

$strip = strip_tags($before);
$after = html_entity_decode($body, ENT_QUOTES, 'UTF-8');

これで $afterが Test Fooになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?