title: How to JSON encode multi-dimensional array?
body: <p>I am creating a array for posting candidate details to an API.
  that API accepts data in JSON format, I am creating a data for the API using PHP array and using JSON encode to convert it JSON array. but not able to get intended format</p>
  
  <p><strong>PHP Code</strong></p>
  
  <pre><code>$postArray = array(
        "DefaultCurrency" =&gt; "USD",
        "UserName" =&gt; "data",
        "Photograph" =&gt; "data",
        "PhotographThumb" =&gt; "data",
        "Group" =&gt; "data",
        "Summary" =&gt; "data",
        "ResumeText" =&gt; "data",
        "RollupListMembership" =&gt; array(
            "RollupCode" =&gt; "data"
          ),
        "CustomFields" =&gt;  array(
            "FieldName" =&gt; "Major",
            "Values" =&gt; array(
              $finalResumeData-&gt; "data"
            ),
            "FieldName" =&gt; "Years of Experience",
            "Values" =&gt; array(
              $MonthsOfWorkExperience
            ),
            "FieldName" =&gt; "Executive Type",
            "Values" =&gt; array(
              $finalResumeData-&gt; "data"
            ),
          )
      );
  </code></pre>
  
  <p><strong>If i run this code as it is its showing only last result of the CustomFields</strong></p>
  
  <p>I have tried using <code>array()</code> for individual <strong>CustomFields</strong> in the array like</p>
  
  <pre><code>"CustomFields" =&gt;  array(
            array("FieldName" =&gt; "Major",
            "Values" =&gt; array(
              $finalResumeData-&gt; "data"
            )),
  </code></pre>
  
  <p>I am getting the results as</p>
  
  <pre><code>CustomFields: {
      "0": {
          "FieldName" : "Value",
          "Values": ["data"]
      }
  }
  </code></pre>
  
  <p><strong>Intended result</strong> </p>
  
  <pre><code>"CustomFields": [
      {
        "FieldName": "string",
        "FieldType": "string",
        "Values": [
          "string"
        ]
      },
      {
        "FieldName": "string",
        "FieldType": "string",
        "Values": [
          "string"
        ]
      }
  ],
  </code></pre>
  
  <p>So what should I update in the PHP array to get intended results.</p>