Home >Web Front-end >JS Tutorial >How to solve the problem of blank space in json_decode

How to solve the problem of blank space in json_decode

coldplay.xixi
coldplay.xixiforward
2020-06-13 17:33:121871browse

How to solve the problem of blank space in json_decode

Solution to the blank issue in json_decode

In fact, I also found this problem online

In fact, this reason is mainly due to the encoding of the returned data, or it may be due to the fact that the interface file contains a BOM. Now let’s cut the nonsense and talk about the solution directly.

Method 1:

$str = 获取json字符串;
$info = json_decode(substr($str, 3), true);
print_r($info);

Additional:

If we include this "stdClass Object" in the parsed code, we can deal with it according to the following method.

Several methods of converting stdClass Object to array in PHP

Recommended tutorial: "JS Basic Tutorial"

The above is the detailed content of How to solve the problem of blank space in json_decode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:liqingbo.cn. If there is any infringement, please contact admin@php.cn delete