How do I find if the column name matches if I have an array? So I have a loop, the name of the column goes from 1 to 6 at the end. Looking to remove the image on click.
This doesn't work. It also doesn't work if I change $i
to 1
in $product_id= "product_gallery_"+[$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";
}
}