I'm dealing with some excessive white space that I want to remove. An example:
Envelopes/Env. Thick/Env. Thin 0 pages
Label 0 pages
Hagaki 0 pages
Replace Count
Drum Unit 0
Toner 0
I've tried to use preg_replace('/\s\s+/', ' ', $content);
but the outcome is not what I expected. The output with preg_replace:
Envelopes/Env. Thick/Env. Thin 0 pages Label 0 pages Hagaki 0 pages Replace Count Drum Unit 0 Toner 0
What I want:
Envelopes/Env. Thick/Env. Thin 0 pages
Label 0 pages
Hagaki 0 pages
Replace Count Drum Unit 0
Toner 0
My code:
<?php
$cw=curl_init("http://192.168.1.135/printer/maininfo.html");
$txtfl=fopen("printermtpage.txt","w");
curl_setopt($cw, CURLOPT_FILE, $txtfl);
curl_setopt($cw, CURLOPT_HEADER, false);
curl_exec($cw);
curl_close($cw);
$file="printermtpage.txt";
$txtopentoread=fopen("printermtpage.txt","r");
$txtread=fread($txtopentoread,filesize($file));
$notags=strip_tags(html_entity_decode($txtread));
$remblanks=preg_replace('/\s\s+/', ' ', $notags);
fclose($txtfl);
?>