[英]In php, increment number is something wrong
我做了作家:評論對編程。 因此,從$ 4到$ 5是第一對評論。 $ arr [even](> = 4)是用戶名,$ arr [odd](> = 5)是$ arr [odd-1]的注釋,即作者名稱。
因此,我正在編寫php代碼。
for ($i=4;$i<count($arr)-1;$i+=2) {
$name = $arr[$i];
$comment = $arr[$i++];
echo $name."<img src='./avatar/".$name.".png' title='".$name."' style='width:19px;height:19px;'> ".$comment."</br>";
}
我正在等待您的好建議。
您正在comment( $i++
)中使用后遞增 ,因此將使用該值,然后對其進行遞增。 因此,這意味着它們在...中都使用相同的$i
值。
$name = $arr[$i];
$comment = $arr[$i++];
當您在循環中增加$i
的值時,我會做...
$name = $arr[$i];
$comment = $arr[$i+1];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.