我有以下的環...內循環迴路引起不希望輸出
for ($i = 1; $i <= 10; $i++) {
echo '<span class="srch-val-'.$i.'">'.apply_filters(" $value\n", $value)."</span>";
}
內...
while ($query->have_posts()) : $query->the_post();
if ($keys = get_post_custom_keys()) {
echo "<div class='clearfix card-prod ".($i==0?'first':'')."'><span class='card-title'>";
echo the_title();
echo "</span>";
foreach ((array) $keys as $key) {
$keyt = trim($key);
if ('_' == $keyt{0} || 'pricing' == $keyt || 'vehicleType' == $keyt || 'coverageRegion' == $keyt || 'locationType' == $keyt)
continue;
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
for ($i = 1; $i <= 10; $i++) {
echo '<span class="srch-val-'.$i.'">'.apply_filters(" $value\n", $value)."</span>";
}
}
echo "\n"; echo '<img src="wp-content/themes/cafc/images/top-choice.jpg" alt="Top Choice" class="topchoice">';echo '<img src="wp-content/themes/cafc/images/cards/dummy.png" />'; echo the_excerpt()."</div>";}
$i++;
ENDWHILE;
然而,當我執行我的代碼,說我的while()循環返回4個值,我對()循環然後輸出同樣的事情10,在瀏覽器中的顯示爲...
所有我想做的事是每個<span class="srch-val'>
是每個「S-RCH-VAL」下課後添加一個數字,所以S-RCH-VAL-1,S-RCH-VAL-2等..
「每個」 是什麼? – bfavaretto 2012-03-26 15:40:33
你能舉一個你想要的輸出的例子嗎?很明顯,for循環會打印10次相同的東西,因爲$ value不會改變。 – flo 2012-03-26 15:42:42
您的意思是免費設置? – 2012-03-26 15:43:04