D
D
del9937882016-11-30 02:54:29
PHP
del993788, 2016-11-30 02:54:29

How to remove quotes in php response?

Hello. Here is a request

$row = json_encode(array_pop($stmt->fetchAll(PDO::FETCH_OBJ)));
echo "$row";

returns me this answer: {"1":"1500","2":"1000","3":"2000" .... }
How do I change the query so that the answer is like this: {"1": 1500,"2":1000,"3":2000 .... } ?
That is, the numbers 1500,1000 and 2000 did not have quotes, but 1, 2 and 3 did.
The db looks like this:
1abd54b657444339a8842ac1437a1c93.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel K, 2016-11-30
@del993788

And actually why?? You get a json encoded string... Where do you need it then??
In general, of course, you can do this: echo json_encode(......., JSON_NUMERIC_CHECK);but something seems to me that you are going to the wrong steppe.

A
Archakov Dennis, 2016-11-30
@archakov06

Perhaps your columns are not INT, but VARCHAR or TEXT. Make them INT in the db.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question