|
@@ -60,14 +60,14 @@ class lyhDemo extends Command |
|
@@ -60,14 +60,14 @@ class lyhDemo extends Command |
|
60
|
if(!empty($aiLists)){
|
60
|
if(!empty($aiLists)){
|
|
61
|
foreach ($aiLists as $item){
|
61
|
foreach ($aiLists as $item){
|
|
62
|
if(!empty($item['seo_description'])){
|
62
|
if(!empty($item['seo_description'])){
|
|
63
|
- $arr = explode('.',$item['seo_description']);
|
|
|
|
64
|
- if($arr[0].'.' != $item['seo_description']){
|
|
|
|
65
|
- echo '进入'.PHP_EOL;
|
63
|
+ //查看当前是否包含句号。
|
|
|
|
64
|
+ $result = $this->hasAnyPeriod($item['seo_description']);
|
|
|
|
65
|
+ if($result === false){
|
|
66
|
$text = $this->trimToLastFullWord($item['seo_description']);
|
66
|
$text = $this->trimToLastFullWord($item['seo_description']);
|
|
67
|
}else{
|
67
|
}else{
|
|
|
|
68
|
+ $arr = explode('.',$item['seo_description']);
|
|
68
|
$text = $arr[0].'.';
|
69
|
$text = $arr[0].'.';
|
|
69
|
}
|
70
|
}
|
|
70
|
- dd($text);
|
|
|
|
71
|
$aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
|
71
|
$aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
|
|
72
|
}
|
72
|
}
|
|
73
|
}
|
73
|
}
|
|
@@ -87,4 +87,8 @@ class lyhDemo extends Command |
|
@@ -87,4 +87,8 @@ class lyhDemo extends Command |
|
87
|
}
|
87
|
}
|
|
88
|
return trim($text); // fallback
|
88
|
return trim($text); // fallback
|
|
89
|
}
|
89
|
}
|
|
|
|
90
|
+
|
|
|
|
91
|
+ public function hasAnyPeriod($text) {
|
|
|
|
92
|
+ return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
|
|
|
|
93
|
+ }
|
|
90
|
} |
94
|
} |