使用while循环计数(在'for循环'中)我不使用长度参数但是这个函数:
function endsWith($haystack, $needle)
{
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
}
在此帮助下,我循环浏览了一系列预览缩略图和pdf-sourcefiles。但我只想数以jpg结尾的文件。所以我的while循环代码是:
while(endWith($page_counter[$rrr], '.jpg')){
$rrr++;
$document_page_count++;
$page_counter['pdf'][$pdf_counting-1]=$document_page_count;
}
我总是得到通知:“Undefined offset:10”。我已经用“isset”尝试了一些东西并将$ rrr与我所有的计数参数进行比较,但它没有帮助。是否有可能以某种方式防止未定义的偏移?对不起,但我无法发布整个代码。
有什么想法吗?
答案 0 :(得分:0)
while (isset($page_counter[$rrr]) && endWith($page_counter[$rrr], '.jpg')) ...