-1

I try to assign the value to my array of object

$models = [new Form()];

    for ($i=0;$i<3;$i++){
        $models[$i]->title = $i;
    }

when I try I got error

Creating default object from empty value

So How can I assign the value more than $models[0]?

Thanks.

1 Answers1

1

I solve this by

$models = [];

for ($i=0;$i<3;$i++){
    $models[$i] = new Form();
    $models[$i]->title = $i;
}

Thanks @castis.