Prevent MySQL PDO from returning numbers as strings
mysql, pdo, php
Solution
If you are using php 5.3.3 or higher you can use `JSON_NUMERIC_CHECK` as the second argument to `json_encode` to do this.
See: https://www.php.net/manual/en/function.json-encode.php
Problem
I am using PHP's PDO to query a MySQL database. It returns numbers and integers as strings, and is messing with my JSON. Is there a better way of fixing it other than type casting the values row by row? ``` array(2) { ["name"]=> string(11) "Preliminary" ["sell_price"]=> string(6) "864.00" } ```