Creating complex json in php -


i want create json array below using array , in php .

{   "1": [     {       "user_id": "1",       "first_name": "akash"     },     {       "user_id": "2",       "first_name": "deepak"     }   ],   "2": [     {       "user_id": "2",       "first_name": "neeru"     },     {       "user_id": "3",       "first_name": "sumit"     }   ] } 

use this

// array here $name_of_your_array=    array (   1 =>    array (     0 =>      array (       'user_id' => '1',       'first_name' => 'akash',     ),     1 =>      array (       'user_id' => '2',       'first_name' => 'deepak',     ),   ),   2 =>    array (     0 =>      array (       'user_id' => '2',       'first_name' => 'neeru',     ),     1 =>      array (       'user_id' => '3',       'first_name' => 'sumit',     ),   ), );  // json encode  $json=json_encode($name_of_your_array); print_r($json); 

if have json decoded data use json_decode function array or use online tools http://freeonlinetools24.com/json-decode


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

html - grunt SVG to webfont -

c# - SharpSsh Command Execution -