Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

return multiple json results

I have to output $var1. To do that, I return results by using

sendJson($var1);

And this is working fine for me. Now I want to pass two variables $var1 and $var2 using sendJson();. Is it possible?

like image 832
Sanu Saji Avatar asked Aug 22 '26 18:08

Sanu Saji


1 Answers

Put them all inside an array:

sendJson(array($var1, $var2));

Or name them if you don't want to do it index-based:

sendJson(array('var1' => $var1, 'var2' => $var2))
like image 166
Rick Kuipers Avatar answered Aug 25 '26 09:08

Rick Kuipers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!