JSON with PHP foreach -
ok per suggestion updated... default laravel returns json... have set return array still getting same row duplicated using:
$limits = array(); foreach($pieces $coverage_limit){ $limits[] = coveragelimit::index($coverage_limit); } return json_encode($limits); }
the $limits array hold last value coveragelimit::index() returns on iterate, suggest check on coveragelimit::index() return value if falls "marc b"'s answer.
edit:
foreach($pieces $key=>$coverage_limit) { $limits[$key] = coveragelimit::index($coverage_limit); }
or
foreach($pieces $coverage_limit) { array_push($limits, coveragelimit::index($coverage_limit)); }
both should returns same marc b's answer
Comments
Post a Comment