Skip to content

Instantly share code, notes, and snippets.

@tomtobac
Created June 23, 2016 14:33
Show Gist options
  • Save tomtobac/a9fa24e91f77b9c5f30ee7b8442241a8 to your computer and use it in GitHub Desktop.
Save tomtobac/a9fa24e91f77b9c5f30ee7b8442241a8 to your computer and use it in GitHub Desktop.
<?php
$obj = array(
"Name" => "Jon Snow",
"Info" => array(
"Age" => "17",
"House" => "Winterfell"
),
"Current Duty" => "Lord Commander"
);
$obj["Family"] = array(
array("Member" => "Arya Stark"),
array("Member" => "Sansa Stark")
);
array_push($obj["Family"], array("Member" => "Bran Stark"));
echo "<pre>" . json_encode($obj) . "</pre>";
?>
@tomtobac
Copy link
Author

Simple Array to json object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment