I am trying to create class properties for each element in an array. The array is already created at this point, I'm just creating it here for demonstration purposes.
I'm not too familiar with classes and objects. Could someone help me out?
class MyClass
{
$days['first'] = "Mon";
$days['second'] = "Tue";
$days['third'] = "Wed";
foreach ($days as $k => $v) {
public $k = $v;
}
}
$obj = new MyClass;
echo $obj->first; // Mon
I keep getting "Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION".