我有这样的功能:
function ypg_delete_img($id, $img)
{
$q = $this->ypg_get_one($id);
$imgs = explode(',', $q->image);
if(count($imgs) > 1) :
$z = ",";
else :
$z = "";
$data['image'] = 'avatar_mali_oglas.png';
$this->db->where('id_yellow_pages', $id);
$this->db->update('yellow_pages', $data);
endif;
if($imgs[0] != 'avatar_mali_oglas.png') :
$query = "UPDATE `yellow_pages` ";
$query .= "SET `image` = REPLACE(`image`,'". $img . $z ."', '')
WHERE `id_yellow_pages` = $id ";
$this->global_functions->delete_img('zute_strane', $img);
$this->db->query($query);
endif;
}
我需要检查$img是否是$imgs数组中的最后一个值。我怎样才能做到这一点?