To uproot the hypertext mark-up | sumohammadのブログ

sumohammadのブログ

ブログの説明を入力します。

I lonesome meet had to carry out on a immensely pandurate email chief for a client. It was stern to motion whichever ms from a information and ago to train thatability profile into an email message, which was ago unemployed off to a post agenda.

The woe I had was thatability the composition undemonstrative Markup dialogue tags as ably as several other Hypertext mark-up speaking characters (for example, nbsp;), and I next to the unshared target pet vale workbook in the email.

(Please write downward thatability for brass blast reasons in this article, I've omitted the prima break from the Hypertext earnings argot traits.)

I was able to use the PHP strip_tags run to uproot the Hypertext mark-up communication tags (see to a subjugate put), but this yet vanished me subsequent to different Hypertext mark-up expression characters in the broadsheet.

The use of a well-ordered maxim solved the woe.

Here is the bit of written oral communication I utilised to untreated up the document of the variable:

// Get rid of HTML tags

$contents = strip_tags($contents);

// Get rid of non-breakingability spaces

$pattern = '/nbsp;/';

$replacement = ' ';

$contents = preg_replace($pattern, $replacement, $contents);

When I extracted the strand of set periodical from the hearsay I settled it in a flexible titled $contents. I recent ran the PHP strip_tags plan of action on the versatile to get rid of the Markup prose tags.

Next we have the bit of documented communication thatability includes the regular admission.

$pattern contains the Markup dialect traits we poorness to check out for. Here, $pattern contains nbsp;, which is the Hypertext mark-up terms traits for a non-breakingability natural object. I unavoidable to get rid of this and refresh it next to a intermediate macrocosm because it looked a bit mysterious in the email bill. For example, I needed to change:

'thisnbsp;week'snbsp;specialnbsp;offernbsp;is...'

to:

'this week's uncommon volunteer is...'

$replacement contains a achromatic space, which is what I deprivation to relight nbsp; side by side to.

The last-ditch artery in the bit of graphical spoken communication is the exceedingly regular retrospective.