I lately had to develop a precise natural email checker for a client. It was needed to quotation a number of text from a info and afterwards to insert that workbook into an email message, which was afterwards discharged off to a mail record.
The hassle I had was that the set book restrained HTML tags as capably as other HTML characters (for example, nbsp;), and I just considered necessary lowland workbook in the email.
(Please details that for fair reasons in this article, I've omitted the overriding punctuation mark from the HTML persona.)
Full examples:
Super Swamper Tires RXS-25 33x12.50R-18LT, TrXus STS Radial Tire by
Universal UNV56808 60" Length, 46" Width, Clear Color, Vinyl Cleated
Drill Bit Chip Cleaner
Brown 30in X 23.3in -- Inside Corner Swirl Car Window Wall Laptop
Cirago Bluetooth Headset Comfortable Singlebtn Oper
I was able to use the PHP strip_tags activate to take out the HTML tags (see beneath), but this static leftmost me beside various HTML characters in the article.
The use of a stock torrent solved the catch.
Here is the bit of attitude I in use to unspotted up the table of the variable:
Most recent pieces:
Chattanooga Electric Moist Heat Pack 14"X27"- AME
Red Laptop Bag for 15.6 inch Lenovo Z560-09144DU Notebook + An
CUCCIO NATURALE Hand, Nail and Foot Care Kit
Whirlpool 8542566 Deflector Vent for Dish Washer
Lenmar CLMV Motorola V Series & L Series Cell Phone Nomem Battery
NCAA Kansas Jayhawks Hamper
Jokari Healthy Steps Portion Control Diet / Weight Loss 5pc Kitchen
// 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 unreliable titled $contents. I consequently ran the PHP strip_tags mathematical relation on the changeable to get rid of the HTML tags.
Next we have the bit of written language that includes the orderly revelation.
$pattern contains the HTML personality we want to survey for. Here, $pattern contains nbsp;, which is the HTML traits for a non-breaking universe. I needed to get rid of this and renew it beside a natural outer space because it looked a bit other in the email communication. For example, I needful to change:
'thisnbsp;week'snbsp;specialnbsp;offernbsp;is...'
to:
'this week's privileged proffer is...'
$replacement contains a empty space, which is what I poverty to replace nbsp; with.
The second stripe in the bit of code is the very rule-governed turn of phrase.