正在显示
1 个修改的文件
包含
5 行增加
和
6 行删除
| @@ -158,13 +158,12 @@ class TranslateLogic extends BaseLogic | @@ -158,13 +158,12 @@ class TranslateLogic extends BaseLogic | ||
| 158 | } | 158 | } |
| 159 | $contentData = array_values($contentData); | 159 | $contentData = array_values($contentData); |
| 160 | $pattern = '/<meta\s+[^>]*name=[\'"](keywords|description)[\'"][^>]*content=[\'"]([^\'"]+)[\'"]/i'; // 匹配 name 为 "keywords" 或 "description" 的 meta 标签的正则表达式 | 160 | $pattern = '/<meta\s+[^>]*name=[\'"](keywords|description)[\'"][^>]*content=[\'"]([^\'"]+)[\'"]/i'; // 匹配 name 为 "keywords" 或 "description" 的 meta 标签的正则表达式 |
| 161 | - $matches1 = array(); | ||
| 162 | - preg_match_all($pattern, $strippedContent, $matches1); | 161 | + $matches = array(); |
| 162 | + preg_match_all($pattern, $strippedContent, $matches); | ||
| 163 | $metaData = array(); | 163 | $metaData = array(); |
| 164 | - foreach ($matches1[1] as $content) { | ||
| 165 | - if (!empty($content)) { | ||
| 166 | - $metaData[] = $content; | ||
| 167 | - } | 164 | + foreach ($matches[2] as $index => $content) { |
| 165 | + $name = $matches[1][$index]; | ||
| 166 | + $metaData[$name] = $content; | ||
| 168 | } | 167 | } |
| 169 | $data = array_merge($metaData, $contentData); | 168 | $data = array_merge($metaData, $contentData); |
| 170 | return $data; | 169 | return $data; |
-
请 注册 或 登录 后发表评论