简体   繁体   中英

how to format result of json_encode

first i have this result with json_ncode :

[{"name":"Pendapatan","y":"1464333560100.00"},{"name":"realpen","y":"500831727342.91"},{"name":"Belanja","y":"1074625188660.00"},{"name":"realbel","y":"239521231607.23"},{"name":"Pembiayaan","y":"52029536970.00"},{"name":"realpem","y":"1809194488.25"}]

when i use str_replace('"','', $result); the data become like this :

[{name:Pendapatan,y:1464333560100.00},{name:realpen,y:500831727342.91},{name:Belanja,y:1074625188660.00},{name:realbel,y:239521231607.23},{name:Pembiayaan,y:52029536970.00},{name:realpem,y:1809194488.25}]

What format should I use to remove the "[]", and leaving only the {a: val, b: val .... etc}

Simplest solution:

substr($yourJson, 1, -1);

Although it is debatable if you should do that this way, as some users in comments already said.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM