title: string arrays within objects within array
body: <p>I am having trouble with a complex issue of stringing arrays within objects within arrays. My current code is as follows:</p>
  
  <pre><code>$responseCountInfo = $responseCount-&gt;data;
  
              foreach ($responseCountInfo as $macKey =&gt; $macVal) {
  
                  $data['MacOrZoneID'][] = $macKey;
  
                  foreach($macVal-&gt;walkbys_by_day as $key =&gt; $val){
  
                      $data['MacOrZoneID'][]['XAxis'][] = $key ;
                      $data['MacOrZoneID'][]['WalkbyTrend']['value'][] = $val ;
  
                  }
  </code></pre>
  
  <p>What it outputs is:</p>
  
  <blockquote>
    <p>{
      "success": true,
      "data": {
        "MacOrZoneID": [
          "AC86744C4820",
          {
            "XAxis": [
              "2016-10-03"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                6555
              ]
            }
          },
          {
            "XAxis": [
              "2016-10-04"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                6471
              ]
            }
          },
          "AC86744F96C0",
          {
            "XAxis": [
              "2016-10-03"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                2941
              ]
            }
          },
          {
            "XAxis": [
              "2016-10-04"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                1934
              ]
            }
          },</p>
  </blockquote>
  
  <p>But I would like to group XAxis and values together instead of repeating them again and again like this</p>
  
  <p>Also, I need the following format</p>
  
  <p><code>macKey</code> as array -> 1st level</p>
  
  <p><code>XAxis</code> and <code>WalkbyTrend</code> key as object and value as array -> 2nd level</p>
  
  <blockquote>
    <p>{
      "success": true,
      "data": {
        "MacOrZoneID": [
          "AC86744C4820",
          {
            "XAxis": [
              "2016-10-03",
              "2016-10-04"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                6555,
                6471
              ]
            }
          },
          "AC86744F96C0",
          {
            "XAxis": [
              "2016-10-03",
              "2016-10-04"
            ]
          },
          {
            "WalkbyTrend": {
              "value": [
                2941,
                1934
              ]
            }
          },    </p>
  </blockquote>
  
  <p>What should I do?</p>