I am using Yii2 framework to create this JSON array:
"data": [
{
"id": 201,
"name": "John",
"age": "30"
}
]
The age is a string and I need it to be an integer, that is, without quotation marks. Like this:
"data": [
{
"id": 201,
"name": "John",
"age": 30
}
]
This is the PHP function that create the JSON array:
$persons['data'] = Persons::find()
->select([
'id',
'name',
'age'
])
->asArray()
->all();
json_decode($array), transform the string in int thenjson_encode($array)to get your array as before.