Having a big problem with json_encode it automatically round off the digits but I need 2 decimal points on every digits.
PHP:
<?php
$numbers = [1.00,2.00];
foreach ($numbers as $i => $number)
{
$numbers[$i] = number_format($number, 2, '.', null);
}
echo json_encode($numbers, JSON_NUMERIC_CHECK);
?>
OUTPUT: [1,2]
EXPECTED OUTPUT: [1.00,2.00]
how can I prevent every digits for not rounding off automatically?
PS: NOT A STRING :)
JSON_NUMERIC_CHECKparameter. It will encode your formatted numbers as strings.