|
|
|
@ -1695,3 +1695,39 @@ if (!function_exists('getChildCategoriesContent')) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 函数名:getDescriptionSeparate (查询表 hc_category 中的字段 description 根据这个字段拆分成数组返回)
|
|
|
|
// 传入 cate_id 和 separate_str, 注意为空的判断;
|
|
|
|
if (!function_exists('getDescriptionSeparate')) { |
|
|
|
function getDescriptionSeparate($cate_id) |
|
|
|
{ |
|
|
|
if (empty($cate_id)) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
$description = \think\facade\Db::table('hc_category') |
|
|
|
->where('id', $cate_id) |
|
|
|
->value('description'); |
|
|
|
|
|
|
|
if (empty($description)) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
|
|
|
|
// 使用正则提取所有以 http:// 或 https:// 开头的链接
|
|
|
|
// 匹配规则:以http(s)开头,直到遇到空白符或中文字符"分隔符"为止
|
|
|
|
preg_match_all('/https?:\/\/[^\s分隔符]+/', $description, $matches); |
|
|
|
|
|
|
|
$result = $matches[0] ?? []; |
|
|
|
|
|
|
|
// 过滤空值并重新索引
|
|
|
|
$result = array_filter($result, function ($value) { |
|
|
|
return !empty(trim($value)); |
|
|
|
}); |
|
|
|
|
|
|
|
return array_values($result); |
|
|
|
} catch (\Exception $e) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
} |
|
|
|
} |