title: Creating a json with array inside PHP?
body: <p>I tried to implement it something like this</p>
  
  <pre><code>private static function getData($datas) {
  
      $days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
      $days_aliases = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
  
      $open_rates = array();
  
      foreach ($datas as $data) {
  
          $date = Carbon::parse($data-&gt;created_at)-&gt;format('l');
  
          for($i = 0; $i &lt; count($days); $i++) {
  
              if($date == $days[$i]){
  
                  $open_rates['x'][$i] = $days_aliases[$i];
                  $open_rates[$data-&gt;name][$i] = (int)$data-&gt;open_rate;
  
              } 
  
          }
  
      }
  
      return $open_rates;
  
  }
  </code></pre>
  
  <p>But the result is like this.</p>
  
  <p>{
  "x": {
  "0": "SUN",
  "1": "MON",
  "2": "TUE",
  "3": "WED",
  "4": "THU",
  "5": "FRI",
  "6": "SAT"
  }
  }</p>
  
  <p>How to make an array like this PHP? </p>
  
  <pre><code>json: {
      'Day Pass' : [40, 10, 99, 50],
      'Day Pass' : [40, 10, 99, 50],
      'Day Pass' : [40, 10, 99, 50],
      'Day Pass' : [40, 10, 99, 50],
      'Day Pass' : [40, 10, 99, 50]
      }
  </code></pre>