Eduardo Fuerte
asked on
Could you point how to handle Undefined Offset Error in Laravel?
Hi Experts
Could you point how to handle Undefined Offset Error in Laravel?
This code:
During the foreach the array of objects is correctly been mounted.
But at certain point this offset error is produced:
Any workaround?
Thanks in advance.
Could you point how to handle Undefined Offset Error in Laravel?
This code:
$registros = array();
for($indexDistribuidor = 0; $indexDistribuidor<count($metas); $indexDistribuidor += 12){
$item = array();
array_push($item, $metas[$indexDistribuidor]->razaosocial);
array_push($item, $metas[$indexDistribuidor]->cnpj);
for($indexMes = 0; $indexMes < 12; $indexMes++){
array_push($item, $metas[$indexDistribuidor + $indexMes]->meta);
}
array_push($item, $metas[$indexDistribuidor]->distribuidor_id);
array_push($item, $ano);
array_push($registros, $item);
}
return $registros;
During the foreach the array of objects is correctly been mounted.
But at certain point this offset error is produced:
Any workaround?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Chris
By using your code the error doesn't occurs at controller but now is occurring at view...
It's due 12 months possible to present data at view.
The previous query that must to generate data have to be adjusted to get only 12 lines per "distribution company".
By using your code the error doesn't occurs at controller but now is occurring at view...
It's due 12 months possible to present data at view.
The previous query that must to generate data have to be adjusted to get only 12 lines per "distribution company".
ASKER
Really
After correcting the query everything is OK.
But your suggestion is pretty good.
Thank you!
After correcting the query everything is OK.
But your suggestion is pretty good.
Thank you!
hi,
you can fix this using isset().
did you try it?