%s', trim($matches[0], '"'), $matches[0]); }, $str); } /** * 从HTML文本中提取所有图片 * * @param string $content HTML文本 * @return array */ public static function getHtmlImage(string $content): array { $pattern = "//"; preg_match_all($pattern, htmlspecialchars_decode($content), $match); $data = []; if (!empty($match[1])) { foreach ($match[1] as $img) { if (!empty($img)) $data[] = $img; } return $data; } return $data; } }