title: php JSON_encode not working
body: <p>I want to get <a href="http://www.wearesliit.com/webapp/modules/quiz/api/?sample" rel="noreferrer">this</a> JSON output from <a href="http://www.wearesliit.com/webapp/modules/quiz/api/read.php" rel="noreferrer">this</a> . unfortunately json_encode() function won't encode array into that format. It's nothing returning at all.  here is my code.`</p>
  
  <pre><code>$output = array(
      'responseData' =&gt; array(),
      'responseDetails' =&gt; null,
      'responseStatus' =&gt; 200
  );
  
  $x = 0;
  while ($row = mysqli_fetch_assoc($result)) {
      foreach ($row as $k =&gt; $v) {
          $output['responseData']['result'][$x][$k] = $v;
      }
      $x++;
  }
  
  print_r($output);
  header('Content-Type: application/json');
  echo json_encode($output , JSON_FORCE_OBJECT);
  </code></pre>
  
  <p>I can't find the reason. someone please help me find the solution.</p>
  
  <p><strong>Edit : Sorry. Here is outputs -</strong></p>
  
  <p>Expected JSON output -</p>
  
  <pre><code>{
  "responseData": {
      "results": [{
          "qid": 1,
          "qtitle": "When do we finish this project ?",
          "qimage_url": "http://www.wearesliit.com/example.png",
          "user": "samith",
          "date": "2016-01-01T02:15:12.356Z",
          "type": 1,
          "category": 5,
          "tags": ["common_senese", "truth", "bazsa_awsanna"],
          "note": "Sample quetion"
      }, {}, {}]
  },
  "responseDetails": null,
  "responseStatus": 200 }
  </code></pre>
  
  <p>I don't get any JSON output at all. but here is the print_r result of the array.</p>
  
  <pre><code> Array(
  [responseData] =&gt; Array
      (
          [result] =&gt; Array
              (
                  [0] =&gt; Array
                      (
                          [question_ID] =&gt; 1
                          [question_Title] =&gt; Which shape does not belong with the other three shapes?
                          [question_Image_URL] =&gt; http://www.wearesliit.com/images/quiz/questions/1.jpg
                          [quetion_Note] =&gt; Easy IQ question.
                          [category_ID] =&gt; 7
                          [username] =&gt; samith
                          [added] =&gt; 2017-01-29 21:50:52
                      )
  
                  [1] =&gt; Array
                      (
                          [question_ID] =&gt; 2
                          [question_Title] =&gt; Tim earns $10 per hour at his job.  When he gets paid on Friday, he is paid for 40 hours of work.  He then goes out and spends 10% of his earnings on entertainment that weekend.  How much money is he left with on Monday?
                          [question_Image_URL] =&gt; 
                          [quetion_Note] =&gt; Easy IQ question.
                          [category_ID] =&gt; 7
                          [username] =&gt; samith
                          [added] =&gt; 2017-01-29 21:50:52
                      )
              )
  
      )
  
  [responseDetails] =&gt; 
  [responseStatus] =&gt; 200 )
  </code></pre>