我想在foreach結構中只使用div一次,因爲當它被多次使用時,找到的圖像都在新行上。我不知道如何從中摘錄div來僅使用它一次。如何從摘錄結構中摘錄div
<?php
include('func.php');
if(isset($_POST['keywords'])){
$suffix = "";
$keywords = mysql_real_escape_string(htmlentities(trim($_POST['keywords'])));
$errors = array();
$results = search_results($keywords);
if ($results === false) {
echo '<h1>We didn\'t find anything for "'.$keywords.'"</h1>';
}
else {
$results_num = count($results);
$suffix = ($results_num!=1)?'s':'';
echo '<h1>',$results_num,' item',$suffix,' For "',$keywords,'"</h1>';
foreach($results as $result){
echo '
<div style="background:rgba(50,0,100,1)">
<span class="overimage">
<a href="',$result['game_url'],'" target="_blank">
<span class="hoverimage">
<span class="hovertext1line-home">',$result['name'],'</span><img class="onlinegameimage-home" src="',$result['image_url'],'" alt=',$result['alt'],'>
</span>
</a>
</span>
</div>
';
}}}
?>
那麼跨度可以重複嗎?你想限制只有權利? – Karthikeyani
是的,跨度可以重複。 – Catchamouse
請在下面檢查我的答案 – Karthikeyani