这是我的代码:$标题的Unicode转换阵列为UTF-8 PHP
<?php
$url = 'https://www.instagram.com/p/BachWpLgFAp/';
$content = file_get_contents($url);
$first_step = explode('edge_media_to_caption": {"edges": [{"node": {"text": "' , $content);
$second_step = explode("}}]}" , $first_step[1]);
$str = $second_step[0];
$str2 = substr($str, 0, -1);
print_r ($str2);
$caption = $str2;
if($user_message == "/test"){
var_dump(bot('sendMessage',[
'chat_id'=>$chat_id,
'text'=>$caption,
]));
}
?>
输出数据是:你\ u2019re活到老,在泥玩。 #tempixel摄影师@ samarthv.pattar在雨后的反射中抛出一个\ u270c \ ufe0f标志。
如何将\ u代码转换为utf-8?
据我所见,所有这些代码都与这个问题无关,实际上可以这样写:“我有一个类似于......的字符串......在他的反射中抛出一个\ u270c \ ufe0f符号......”并且需要将'\ u'转义转换为UTF-8。“ – IMSoP
使用[mb_convert_encoding()](http://php.net/manual/en/function.mb-convert-encoding.php) – Jeff
你是否手动拆分json-string?你为什么不只是'json_decode'呢? – Jeff