遍历文章列表,提取<img>标签的src内容,代码参考home.html:
$sliderdatas = $_G['TABLE']['READ'] -> getDatas(0, 100, 'where `del`=false order by `id` desc');
$i = 0;
foreach ($sliderdatas as $sliderdata) {
if (preg_match_all('#<img.*?src="(.*?)".*?alt="(.*?)".*?\>#', $sliderdata['content'], $match)) {
$noimglist = 'emotion';
foreach ($match[1] as $key => $value) {
if (!InArray($noimglist, $match[2][$key])) {
$i++;
$hshtml .= '<li><a target="_blank" href="' . ReWriteURL('read', "id={$sliderdata['id']}&page=1") . '"><img src="' . $value . '" alt="Image"></a><p class="caption">' . $sliderdata['title'] . '</p></li>';
if ($i >= $hslc) {
break 2;
}
break;
}
}
}
}