Forum

2 dimensional JSON array

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?

pipasha
pipasha
  • 1 month 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.