我想要一个 json_decode 一个需要特定格式的字符串,但我的字符串包含一些额外的文本,所以我想剪切字符串中不固定的部分。我想从特定字符“{”中剪切。那么我怎样才能剪切该文本。
我尝试了这两个函数 substr() 和 strpos() 但这些函数返回我想要删除的字符串。从这里 PHP Cut String At specific character .
$responseArray = http_post_with_status_code($url, $post_string, "application/json", false, $options);
$rawResponse = $responseArray['message'];
// This is the expected output of $rawResponse.
$rawResponse = http code:200 Output:{
"QueryResponse" : {
"Header" : {
"DateTime" : "2019-04-16T07:24:41.718Z",
"MessageID" : "1111111111111111111111"
},
}
}
没有这些字符的字符串(http代码:200输出:)
最佳答案
关于php - 如何从特定字符中剪切动态字符串并将剩余部分保留在变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55758503/