I am working with laravel and trying to get value of an array after another value using foreach loop. I am wondering what would be the best practice in solving this problem. So far I have tried this
$problems = $request->session()->get('problems');
$i = 0;
foreach ($problems as $prob) {
$problem = $prob;
if($request->problem_id == $prob->id){
return 'Matched';
die();
}
$i++;
}
[1,2,3,4]if you have the value 3 you want the 4th element?die();. Since you have areturnbefore it, it will never get triggered.