【发布时间】:2018-04-01 09:16:39
【问题描述】:
这是我的代码:
<?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,
]));
}
?>
$caption 的输出数据是: 你永远不会老到不能玩泥巴。 #teampixel 摄影师 @samarthv.pattar 在雨后向他的倒影投掷 \u270c\ufe0f 标志。
如何将 \u 代码转换为 utf-8?
【问题讨论】:
-
据我所知,所有这些代码都与问题无关,实际上可以表述为“我有一个类似
...throws a \u270c\ufe0f sign at his reflection...的字符串,需要将\u转义转换为UTF-8。” -
您是手动拆分 json 字符串吗?你为什么不直接
json_decode呢?? -
@Gajanan Kulkarni 。我的代码给出了 Instagram 帖子的标题,但是输出中的字符是 unicode,我想要 utf-8
-
@Jeff 在哪里使用?当我使用 json_decode($str2);没有输出。
标签: php arrays unicode utf-8 telegram-bot