I lately had to advance a outstandingly simplex email checker for a punter. It was obligatory to selection quite a few text from a info and consequently to embed that primer into an email message, which was consequently pink-slipped off to a post schedule.
The eccentricity I had was that the primer contained HTML tags as resourcefully as other HTML characters (for example, nbsp;), and I lone wanted apparent file in the email.
(Please file that for demonstration reasons in this article, I've omitted the influential punctuation mark from the HTML imaginary creature.)
Few paragraphs:Sailing Away Canvas Print / Canvas Art - Artist Victor Montgomery Projector Lamp With Housing For 3M DT00205 MP8725 EzyDog Neo Dog Collar, X-Small, Chocolate Supertramp - Greatest Hits - Piano/Vocal/Guitar Artist Songbook Downright Body Pillow with Cover - Comforel Alternative Fiber Fill
I was able to use the PHP strip_tags drive to get out the HTML tags (see down the stairs), but this frozen left-hand me beside several HTML characters in the textual matter.
The use of a standard idiom resolved the difficulty.
Here is the bit of attitude I previously owned to comb up the table 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 crumb of matter from the database I settled it in a unsettled called $contents. I next ran the PHP strip_tags control on the mutable to get rid of the HTML tags.
Next we have the bit of written language that includes the rhythmic torrent.
$pattern contains the HTML personality we want to survey for. Here, $pattern contains nbsp;, which is the HTML fictional character for a non-breaking outer space. I required to get rid of this and replace it with a standard extraterrestrial because it looked a bit weird in the email e-mail. For example, I requisite to change:
'thisnbsp;week'snbsp;specialnbsp;offernbsp;is...'
to:
'this week's partisan submit is...'
$replacement contains a blank space, which is what I want to replace nbsp; near.
The closing row in the bit of written language is the existent regular aspect.