作者 lyh

gx

@@ -164,16 +164,19 @@ class ProofreadingController extends BaseController @@ -164,16 +164,19 @@ class ProofreadingController extends BaseController
164 $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式 164 $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式
165 $matches = array(); 165 $matches = array();
166 preg_match_all($pattern, $strippedContent, $matches); 166 preg_match_all($pattern, $strippedContent, $matches);
167 - $data = [];  
168 - $textContentArray = $matches[1];  
169 $textContentArray = array_filter($matches[1], function($item) { 167 $textContentArray = array_filter($matches[1], function($item) {
170 return !empty(trim($item)); 168 return !empty(trim($item));
171 }); 169 });
172 - var_dump($textContentArray);  
173 - die();  
174 - $uniqueArray = array_unique($data); 170 + $textContentArray = array_values($textContentArray);
  171 + $uniqueArray = array_unique($textContentArray);
175 $textContentArray = array_values($uniqueArray); 172 $textContentArray = array_values($uniqueArray);
176 - return $textContentArray; 173 + $data = [];
  174 + foreach ($textContentArray as $v){
  175 + $content = trim($v);
  176 + $trimmedString = preg_replace('/\s+/', ' ', $content);
  177 + $data[] = $trimmedString;
  178 + }
  179 + return $data;
177 } 180 }
178 181
179 /** 182 /**