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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -