title: Converting PHP array to a single JSON object using js
body: <p>I have a php array(zero indexed) which I am sending to front end directly by echoing its json_encode format.</p>
  
  <p>I want the JSON object to look like </p>
  
  <pre><code>{
      'A': null,
      'B': null,
      'C': null
  }
  </code></pre>
  
  <p>But when I tried console.log i.e.,</p>
  
  <pre><code>console.log(&lt;?php echo json_encode($array); ?&gt;)
  </code></pre>
  
  <p>its printing js array</p>
  
  <p>Also when I try print_r($array) in backend it prints</p>
  
  <pre><code>[array] =&gt; Array
      (
          [0] =&gt; A
          [1] =&gt; B
          [2] =&gt; C
  
      )
  </code></pre>
  
  <p>Thanks in advance</p>