首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >json_encode在数组上返回null

json_encode在数组上返回null
EN

Stack Overflow用户
提问于 2014-12-30 22:27:05
回答 1查看 203关注 0票数 0

我正在尝试json_encode一个php数组,但是“选择”部分返回null。

代码语言:javascript
复制
Array ( [indexer] => 7 [section] => 1 [question] => What does the last paragraph indicate about an optimistic perspective? [answer] => a [choices] => There has never been a culture or religion that is genuinely optimistic`It is “a riddle of the universe”`No enlightened culture sees the world in a truly optimistic manner`Optimistic perspectives are only held by the weak )

{"indexer":"7","section":"1","question":"What does the last paragraph indicate about an optimistic perspective?","answer":"a","choices":null}

知道为什么吗?

编辑:完整代码:

代码语言:javascript
复制
$check = mysqli_query($con, "select * from questions where section = '$section' and indexer = '$question'");
$result = mysqli_fetch_array($check, MYSQLI_ASSOC);

print_r($result);
echo json_encode($result);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-30 22:58:11

编码,编码期望您编码的所有内容都是有效的UTF-8。如果内容的任何部分不是正确的UTF-8,json_encode将为该部分(b )默默地失败。

所有字符串数据必须被UTF-8编码.

我的猜测是,标记没有正确地编码UTF-8 (而是起源于基于CP1252的编码)。

请参阅错误从json模块检索最后一个错误代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27713496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档