我正在处理一些我想删除的过多空白。一个例子:
Envelopes/Env. Thick/Env. Thin 0 pages
Label 0 pages
Hagaki 0 pages
Replace Count
Drum Unit 0
Toner 0
我尝试过使用preg_replace('/\s\s+/', ' ', $content);
,但结果不是我所期望的。preg_replace 的输出:
Envelopes/Env. Thick/Env. Thin 0 pages Label 0 pages Hagaki 0 pages Replace Count Drum Unit 0 Toner 0
我想要的是:
信封/信封。厚/环境。薄 0 页
标签 0 页
Hagaki 0 页
更换计数鼓单元 0
墨粉 0
我的代码:
<?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);
?>