It0*_*007 -1 javascript php arrays
我可以从字符串变量中提取数组:
HTTP/1.1 200 OK
Server: YYYYYYYYY
Content-Type: application/json
Content-Length: 163
X-OAPI-Request-Id: XXXXXXXXXXXXXX
{
"token_type": "berber",
"access_token": "XXXXXXXXYYYYYYY",
"expires_in": "7776000"
}
Run Code Online (Sandbox Code Playgroud)
我想获得具有token_type,access_token,expires_in的数组。
它有点像json,因此您可以修剪掉不是json的部分,然后使用json_decode对其进行解码。
$arr = json_decode(substr($str,strpos($str,"{")), true);
Var_dump($arr);
Run Code Online (Sandbox Code Playgroud)
在这里,我从“ {”到字符串结尾发送到json_decode,返回:https ://3v4l.org/r8VgO