For example nbsp and i | sjavier6のブログ

sjavier6のブログ

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

I late had to fall into place a highly austere email supervisor for a case. It was called for to citation several workbook from a info and then to introduce that essay into an email message, which was afterwards laid-off off to a mail list.

The hassle I had was that the file restrained HTML tags as ably as another HTML characters (for example, nbsp;), and I sole longed-for unembellished schoolbook in the email.

(Please memo that for retrospective reasons in this article, I've omitted the ascendant punctuation mark from the HTML part.)

Few reports:

I was able to use the PHP strip_tags work to get out the HTML tags (see downwards), but this frozen nigh me near several HTML characters in the essay.

The use of a rhythmical revelation resolved the bother.

Here is the bit of codification I used to brush up the table of contents of the variable:

// Get rid of HTML tags

$contents = strip_tags($contents);

// Get rid of non-breaking spaces

$pattern = '/nbsp;/';

$replacement = ' ';

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

When I extracted the piece of paper from the information I placed it in a inconstant called $contents. I then ran the PHP strip_tags activate on the unreliable to get rid of the HTML tags.

Next we have the bit of standard that includes the official spate.

$pattern contains the HTML part we privation to hunt for. Here, $pattern contains nbsp;, which is the HTML part for a non-breaking opportunity. I necessary to get rid of this and renew it beside a sane scope because it looked a bit peculiar in the email communication. For example, I needful to change:

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

to:

'this week's marked proffer is...'

$replacement contains a white space, which is what I privation to regenerate nbsp; beside.

The ultimate column in the bit of belief is the actual rhythmic look.