XF 2.2 fields as vars?

Robert9

Well-known member
How can I do:
Code:
$item->color =
$item->size =
$item->weight =

as

Code:
$fieldList = "color,size,weight";
$fieldArray = explode(",",$fieldList);
foreach ($fieldArray as $k => $v)
{
 $item->$v = something;
}
 
Last edited:
Seems to work with $item->{$v} = something;
and there should be no spaces inside the list "color,size,weight";
 
Back
Top Bottom