Back

2 dimensional JSON array


pipasha posted 6 months ago

I want to create 2 dimensional JSON array from database. The format will be as followings [ {"id":"856","name":"House"}, {"id":"1035","name":"Desperate Housewives"}, ... ]

Can anybody kindly give any idea?

saurabhd replied 6 months ago

For creating 2 dimensional json array, follow below example code:

$fetch = DB::table('table_name')->get();

{{json_encode($fetch)}}

Hope, this work for you.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us