Create nested JSON object in PHP?


JSON structure can be created with the below code −

$json = json_encode(array(
   "client" => array(
      "build" => "1.0",
      "name" => "xxxx",
      "version" => "1.0"
   ),
   "protocolVersion" => 4,
   "data" => array(
      "distributorId" => "xxxx",
      "distributorPin" => "xxxx",
      "locale" => "en-US"
   )
));

Updated on: 07-Apr-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements