J
J
Jlewka2016-03-18 15:32:36
PHP
Jlewka, 2016-03-18 15:32:36

PHP server outputs decimal characters instead of numbers. How to output a number normally?

Good afternoon.
The problem is this: I make an AJAX request to the server, in the response to which there is an attribute with a float value. So this value is printed in such a way that the numbers are replaced with alphabetic characters (for example, it should be 576.28, but it turns out 1.INPPPPPPPPPPQ). As a result, JS cannot parse such a response.
Moreover, if this number is used twice, then everything is in order.
I tried to print this number in a separate script - in order.
The code:

$result = array(
  'status' => 1
);
$value = 0.0;
// $someArray = array(array('value'=>1.0),array('value'=>5.2),...)
foreach($someArray as $item){
  $value += $item['value'];
}
$result['value'] = $value;
die(json_encode($result));

How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2016-03-18
@skobkin

Let's turn on the logic. Given:
- A code that explicitly says to print a certain number prints it correctly
- Your code prints the code incorrectly
- You want someone to help you fix the code
Question: what is missing to solve the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question