// 提取第一個標簽中的 URL
function extractFirstImgUrl($text) {
$pattern = '/\[img\](.*?)\[\/img\]/i'; // 匹配中的內容
if (preg_match($pattern, $text, $match)) {
return $match[1]; // 返回第一個匹配的 URL
}
return null; // 如果沒有匹配到 URL,返回 null
}
$firstImageUrl = extractFirstImgUrl($text);
'image'=>$firstImageUrl
歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) | Powered by Discuz! W1.0 |