for($i=0;$i<count($status);$i++)
{
$conf = array(
'source_image' => $status[$i]['full_path'],
'new_image' => $this->upload_path . '/thumbs',
'maintain_ratio' => true,
'width' => 200,
'height' => 200
);
$this->load->library('image_lib', $conf);
$this->image_lib->resize();
$this->image_lib->clear(); // complete reset
$this->image_lib->initialize($conf); // complete reset
}
.
始终保持错过最后一个缩略图创建周期。当尝试 for($ i = 0; $ i&lt; = count($ status); $ i ++)时。我得到这个通知未定义的偏移量
答案 0 :(得分:2)
通过使用for
循环,您假设数组的键是连续的,它们可能不是。您还假设每个二级数组都有一个full_path
键,它可能没有。请改用foreach
,并对isset()
键进行full_path
检查:
foreach ($status as $item)
{
if (!isset($item['full_path'])) continue;
$conf = array(
'source_image' => $item['full_path'],
'new_image' => $this->upload_path . '/thumbs',
'maintain_ratio' => true,
'width' => 200,
'height' => 200
);
$this->load->library('image_lib', $conf);
$this->image_lib->resize();
$this->image_lib->clear(); // complete reset
$this->image_lib->initialize($conf); // complete reset
}
答案 1 :(得分:0)
试试这个:
$this->load->library('image_lib');
$stat = array_values($status);
for($i=0;$i<count($stat);$i++)
{
$conf = array(
'source_image' => $stat[$i]['full_path'],
'new_image' => $this->upload_path . '/thumbs',
'maintain_ratio' => true,
'width' => 200,
'height' => 200
);
$this->image_lib->initialize($conf); // complete reset
$this->image_lib->resize();
}