Issue
My Code Having Json Response Like this
["0","0","0","0","0","0","204.4"]
Need Like This
[ 0, 0, 0, 0, 0, 0, 204.4 ]
For this I have done codeigniter
$query = $this->db->query($selectQuery);
$totalInvoice = array();
foreach ($query->result() as $row)
{
$totalInvoice[] = $row->total;
}
print_r(json_encode($totalInvoice));
This Response is
["0","0","0","0","0","0","204.4"]
Solution
Add JSON_NUMERIC_CHECK (integer) when encode in json.
JSON_NUMERIC_CHECK (integer) : Encodes numeric strings as numbers
$query = $this->db->query($selectQuery);
$totalInvoice = array();
foreach ($query->result() as $row)
{
$totalInvoice[] = $row->total;
}
print_r(json_encode($totalInvoice, JSON_NUMERIC_CHECK);
Answered By - Madhuri Patel Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.