我正在嘗試解析未定義的偏移量。我有谷歌並且通過堆棧溢出來看,但是我發現的例子不適用,或者對於我目前熟悉的人來說太複雜了。我非常環保,但我在做出努力之前,我曾經保證過要求幫助和智慧。函數返回未定義的偏移量錯誤
這是因爲它現在存在於功能:
function PrintFolio($aaPh) //aaPh =associative array place holder
{
//print out X number rows of unto 4 images from array with X items
//if array had 7 items, print one row of 4 next row 3
//if array had 16 items, print 4 rows of 4, etc.
//if array had 13 items, print 3 rows of 4, final row with one item
$itemsCount = sizeof($aaPh);//get size of array
$height = (int)ceil(sizeof($aaPh)/4);//rounded up division by 4
//$height = $height + 1;
$keys = array_keys($aaPh); //get keys
//loop through array of X items, for each group of 4 print as a row
for($row = 0; $row < $height; $row++) //looping through the rows
{
echo '<div class="row flush">'; //open div
for($image = 0; $image < 4; $image++) //each row is composed of 4 images
{
$aaPhIndex = array_keys($aaPh)[$row*4+$image]; //if associative array
if($row*4+$image < $itemsCount) {
$aaPhIndex = $keys[$row*4+$image];
printf(TEMPLATE_PORTFOLIO, $aaPhIndex, $aaPh[$aaPhIndex]);
//$template = '<div class="3u"><a href="_img/fulls/%1$s" class="image full"><img src="_img/thumbs/%1$s" alt="" title="%2$s" /></a></div>';
}
}
echo '</div>'; //end div group of 4
}//end loop
}//end function
它帶有一個數組,切片它在到的四個單元,然後打印該陣列爲一系列圖像到屏幕。但是,如果我沒有一個數字是4可以設置的,它將顯示任何未定義的偏移量錯誤(我希望我正確地說)。
- 我的目標是不會有不確定的偏移誤差打印到這些屏幕,不修改我的網站錯誤報告功能(我認爲這樣做會被欺騙,因爲它不會解決問題,只是將其隱藏它沒有按」對我來說似乎非常重要)。
我跑了這一點,當我這樣做,不返回任何補償,但不返回任何圖像或者(所以我一定不能正確理解的東西時,我代替我,如果你如果)。那是你建議我做的,如果你的建議取代了我的意見? – Chezshire
你用你的圖片輸出代碼替換了我的(/ *在這裏顯示你的圖片代碼* /)嗎? :) – cyadvert
請給出一個示例數據$ aaPh請 – cyadvert