Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:55:57+00:00 2026-06-13T22:55:57+00:00

I am using json_encode to convert PHP arrays to json and it seems to

  • 0

I am using json_encode to convert PHP arrays to json and it seems to work fine except for one thing.

If I have a multi-dimensional array like this:

$person = array(
  'name' => 'John Smith',
  'age' => 36,
  'siblings' => array(
    'male' => array('John Doe','Mark'),
    'female' => array('Jane Doe','Jane Smith')
  )
);

I want it to put brackets around siblings but it only does it around male and female, i.e:

{
  "name":"John Smith",
  "age":36,
  "siblings":{
    "male":[
      "John Doe",
      "Mark"
    ],
    "female":[
      "Jane Doe",
      "Jane Smith"
    ]
  }
}

And I want "siblings":[{ ... }]

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:55:58+00:00Added an answer on June 13, 2026 at 10:55 pm
    $person = array(
      'name' => 'John Smith',
      'age' => 36,
      'siblings' => array(array(
        'male' => array('John Doe','Mark'),
        'female' => array('Jane Doe','Jane Smith')
      ))
    );
    

    This will give exactly what you want but it doesn’t make much sense

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I convert my php array to json using json_encode, Than I record this json
I'm using php's json_encode() to convert an array to json which then echo's it
Background: Using jQuery 1.7 client side PHP server side Using json responses with json_encode
This piece of valid json (it has been generated using php's json_encode): {html:form is
I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing
I am trying to convert some xml into a json object using PHP. This
Could not convert or access JSON object from PHP json_encode <?php $f_array = array();
How to convert MySQL data base table into JSON data using PHP. Is there
When using PHP's json_encode to encode an array as a JSON string, is there
I have an array that is being encoded in php using json_encode $params =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.