度“°"字符未显示在php json_encode函数中,如何显示? [英] Degree '°' character not displaying in php json_encode function, how to display this?

查看:102
本文介绍了度“°"字符未显示在php json_encode函数中,如何显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我像这样传递php数组

I pass php array like

[sit_latitude] => 20° 23.298' N

在json_encode()内部;输出就像,

inside json_encode(); and output is like,

  {"sit_latitude":null}

显示为空,如何解决?

it's display null, how to resolve this?

我的代码段

...
$stmt->bindParam("id", $_GET[id]);
$stmt->execute();
$employee = $stmt->fetchObject();
$dbh = null;
echo '{"item":'. json_encode($employee) .'}';

推荐答案

我尝试并成功的方法有点奇怪,但是可以解决,所以让我与您分享.

what i tried and succeed was bit strange but worked , so let me share it with you.

$latitude = json_encode(utf8_encode($emplyoee['sit_latitude']));
$longitude = json_encode(utf8_encode($employee['sit_longitude']));

   $emplyoee['sit_latitude'] = $latitude;
    $emplyoee['sit_longitude'] = $longitude;

现在通过

echo '{"item":'. json_encode($employee) .'}';

这将解决您的问题

这篇关于度“°"字符未显示在php json_encode函数中,如何显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆