我想從文本文件中使用file_get _contents僅獲取refresh_token字段。請任何人解決此問題。如何從文本文件中的對象數組中獲取特定字段
{"access_token":"XXXX","token_type":"bearer","expires_in":3600,"refresh_token":"XXXX"}
我想從文本文件中使用file_get _contents僅獲取refresh_token字段。請任何人解決此問題。如何從文本文件中的對象數組中獲取特定字段
{"access_token":"XXXX","token_type":"bearer","expires_in":3600,"refresh_token":"XXXX"}
那是一個JSON字符串
$content = file_get_contents([...]);
$arr = json_decode($content);
echo $arr->access_token;
感謝它的工作原理:) –
JSON的操作,你應該使用json_decode
$str= file_get_contents(some.txt);
$array = json_decode($content);
echo $array->access_token;
謝謝你:) –
'回聲$對象 - > refresh_token' –
試過,不工作:( –