mardi 2 mars 2021

Creating array variable in collection loop

I get data from query and running a foreach loop on it.

foreach($result as $data)
{
    $myVar[$data->flag][$data->year]['totalActions'] += $data->totalActions;
}

"Undefined variable: contractDetails"

When I create a variable before loop like $myVar = []

Then it gives me the error "Undefined index: All"

Here All is value of $data->flag

How to handle this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire