我正在创建一个api,我在其中获取包含列的一些特殊字符值的数据,当我以json格式转换它时,它的值从100¢变为100¢â€。我不想要这个额外的角色。
这是我的代码
$UserDetailSql = "SELECT * FROM `characteristic` WHERE event_id='" . $events->id . "'";
//$this->_db->my_query("SET NAMES 'UTF8'");
$UserDetailSqlVal = $this->_db->my_query($UserDetailSql);
$temp_char = array();
while($characteristic = $this->_db->my_fetch_object($UserDetailSqlVal)){
$char_temp['characteristic_id'] = $characteristic->characteristic_id;
$char_temp['title_description'] = $characteristic->title;
$char = $this->_common->getEventCharacterstics($characteristic->characteristic_id);
$char_temp['title'] = $char->title;
$char_temp['image'] = IMG_PATH.'characterstics/'.$char->image;
$temp_char[] = $char_temp;
}
$temp['characteristic'] = $temp_char;
echo json_encode($temp);`
此处$characteristic->title
可以包含加泰罗尼亚语或西班牙语或英语数据。我在标题中给出的值是此列。
我尝试了utf8_encode()
,htmlentities()
,htmlspecialcharacters()
但没有运气请帮助我现在厌倦了。谢谢你。