troubleshooting Question

Could you point  how to handle Undefined Offset Error in Laravel?

Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil asked on
LaravelPHP
4 Comments1 Solution91 ViewsLast Modified:
Hi Experts

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:

 img004
Any workaround?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros