Home  >  Article  >  Backend Development  >  How to create nested JSON objects in PHP?

How to create nested JSON objects in PHP?

WBOY
WBOYforward
2023-08-19 13:45:371223browse

How to create nested JSON objects in PHP?

The JSON structure can be created using the following 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"
   )
));

The above is the detailed content of How to create nested JSON objects in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete