0
배열이있는 경우 열 이름이 일치하는지 어떻게 알 수 있습니까? 저는 루프가 있습니다. 칼럼의 이름은 1에서 6까지입니다. 클릭시 이미지를 삭제하려고합니다.yii에 지정된 배열과 열 이름이 일치하는지 확인하는 방법
이것은 작동하지 않습니다. 내가 $product_id= "product_gallery_"+[$i];
에 1
에 $i
을 변경하는 경우에도
for ($i=1; $i<=6; $i++)
{
$product_img= "product_gallery_"+[$i];
if($model->getAttributeLabel($product_id)==$image_attr) // not sure about $image_attr either, it was passed from view
{
$filename = $model->$product_img;
unlink($path.$filename);
$model->product_gallery_[$i] = "default.png";
$model->save();
echo "removed";
}
}
의
$key
요소에 액세스 할$variable[$key]
를 예에 액세스 할 수없는 키에 의한 배열 요소를 해결하기 위해 사용 $ i? +는 PHP 연결 연산자가 아닙니다 – Anigel"product_gallery_"와 [$ i]를 연결하려면 '.'을 사용해야합니다. '+'나는 생각하지 않습니다. – MisterJ
아하하 .. 알았어! 감사 – JamAndJammies