title: Convert json string to integer in php
body: <p>I'm using xampp and even though I've set the id column as integer in my table, the output is still string i.e I get <code>"id":"1"</code> instead of <code>"id":1</code>. I've come across a possible solution via <code>JSON_NUMERIC_CHECK</code> but I don't know how to implement this in my php script. Can someone show me how to modify my php script in order to have the id output as an integer.</p>
  
  <pre><code>    &lt;?php
  
  
      require("config.inc.php");
      $query_params=null;
  
  
  
      $query = "Select * FROM feeds";
  
  
      try {
          $stmt   = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($query_params);
      }
      catch (PDOException $ex) {
          $response["success"] = 0;
          $response["message"] = "Database Error!";
          die(json_encode($response));
      }
  
  
      $rows = $stmt-&gt;fetchAll();
  
  
      if ($rows) {
          $response["feed"]   = array();
  
          foreach ($rows as $row) {
              $post             = array();
              $post["id"] = $row["id"];
              $post["name"]    = $row["name"];
              $post["image"]  = $row["image"];
  
              array_push($response["feed"], $post);
          }
  
  
          echo json_encode($response);
  
  
      } else {
          $response["success"] = 0;
          $response["message"] = "No Post Available!";
          die(json_encode($response));
      }
  
  ?&gt;
  </code></pre>