gpt4 book ai didi

php json_encode 返回空值

转载 作者:可可西里 更新时间:2023-11-01 12:24:59 25 4
gpt4 key购买 nike

Array
(
[sEcho] => 1
[iTotalRecords] => 7521
[iTotalDisplayRecords] => 1
[aaData] => Array
(
[0] => Array
(
[0] => Nordic Capital Buys SiC Processing
[1] => 2010-06-21/nordic-capital-buys-sic-processing
[2] => PEHub Media
[3] => Business
[4] => completed
[5] => Nordic Capital has acquired a 70% stake in SiC Processing AG, a German industrial recycling company, from Frog Capital. No sale price was disclosed. SiC Processing’s founding family retains a 25% holding, while former lead investor Zouk Ventures retains a 5% stake.

[6] => Admin, China, Frog Capital, Germany, Italy, Iyad Omari, Manufacturing, Norway, PEHub Media, Photovoltaic Wafer Manufacturing, Renewable Energy, Semiconductor, United States
)

)

)

echo json_encode($myArr);

{"sEcho":"1","iTotalRecords":7521,"iTotalDisplayRecords":"1","aaData":[[" Nordic Capital Buys SiC Processing</a></div>"," 2010-06-21/nordic-capital-buys-sic-processing</div>","PEHub Media","Business","completed",null," Admin, China, Frog Capital, Germany, Italy, Iyad Omari, Manufacturing, Norway, PEHub Media, Photovoltaic Wafer Manufacturing, Renewable Energy, Semiconductor, United States]]}

完成后注意字符串中间的null

这是为什么,我需要执行什么转义/操作才能对其进行编码?

我试过了,addslashes

最佳答案

来自手册:

Note that if you try to encode an array containing non-utf values, you'll get null values in the resulting JSON string. You can batch-encode all the elements of an array with the array_map function:

$encodedArray = array_map(utf8_encode, $myArr);
echo json_encode($encodedArray);

关于php json_encode 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3180690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com