Php 使用空格访问json结果
我从一个API得到一个json结果。问题中出现的一个关键点,而不是像这样的真正关键点:Php 使用空格访问json结果,php,json,Php,Json,我从一个API得到一个json结果。问题中出现的一个关键点,而不是像这样的真正关键点: {"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"} $json_string = '{"somthing":"12345","questions":[{"Question Here ab
{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}
$json_string = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$json = json_decode($json_string, true);
$questions = $json['questions'];
for($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
foreach($question as $key => $value) {
echo "Question: " . $key . "\n";
echo "Answer:" . $value . "\n";
}
}
“这里有一些问题。这里也有类似的引语”
将始终保持不变,但如何访问其值(thevalue)
我正在尝试类似的东西:
$result = json_decode($jsonresult);
echo $result->questions->Question Here about something. There are also quotes like this \"here\");
但由于空格和转义引号的存在,这不起作用。有什么建议吗 试试下面的方法:
$jsonresult = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$result = json_decode($jsonresult);
echo $result->questions[0]->{'Question Here about something. There are also quotes like this "here")';
这将导致值
请尝试以下操作:
$jsonresult = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$result = json_decode($jsonresult);
echo $result->questions[0]->{'Question Here about something. There are also quotes like this "here")';
这将导致值
请尝试以下操作:
$jsonresult = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$result = json_decode($jsonresult);
echo $result->questions[0]->{'Question Here about something. There are also quotes like this "here")';
这将导致值
请尝试以下操作:
$jsonresult = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$result = json_decode($jsonresult);
echo $result->questions[0]->{'Question Here about something. There are also quotes like this "here")';
这将导致
值
一种更简单的方法是将JSON字符串转换为PHP关联数组,如下所示:
{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}
$json_string = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$json = json_decode($json_string, true);
$questions = $json['questions'];
for($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
foreach($question as $key => $value) {
echo "Question: " . $key . "\n";
echo "Answer:" . $value . "\n";
}
}
$json_string='{“somthing”:“12345”,“questions”:[{“Question Here about something.”也有类似这样的引号\“Here\”:“thevalue”}],“id”:“123455”};
$json=json_解码($json_字符串,true);
$questions=$json['questions'];
对于($i=0;$i$value的问题){
回显“问题:.$key.\n”;
回显“应答:“.$value.”\n;
}
}
更简单的方法是将JSON字符串转换为PHP关联数组,如下所示:
{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}
$json_string = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$json = json_decode($json_string, true);
$questions = $json['questions'];
for($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
foreach($question as $key => $value) {
echo "Question: " . $key . "\n";
echo "Answer:" . $value . "\n";
}
}
$json_string='{“somthing”:“12345”,“questions”:[{“Question Here about something.”也有类似这样的引号\“Here\”:“thevalue”}],“id”:“123455”};
$json=json_解码($json_字符串,true);
$questions=$json['questions'];
对于($i=0;$i$value的问题){
回显“问题:.$key.\n”;
回显“应答:“.$value.”\n;
}
}
更简单的方法是将JSON字符串转换为PHP关联数组,如下所示:
{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}
$json_string = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$json = json_decode($json_string, true);
$questions = $json['questions'];
for($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
foreach($question as $key => $value) {
echo "Question: " . $key . "\n";
echo "Answer:" . $value . "\n";
}
}
$json_string='{“somthing”:“12345”,“questions”:[{“Question Here about something.”也有类似这样的引号\“Here\”:“thevalue”}],“id”:“123455”};
$json=json_解码($json_字符串,true);
$questions=$json['questions'];
对于($i=0;$i$value的问题){
回显“问题:.$key.\n”;
回显“应答:“.$value.”\n;
}
}
更简单的方法是将JSON字符串转换为PHP关联数组,如下所示:
{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}
$json_string = '{"somthing":"12345","questions":[{"Question Here about something. There are also quotes like this \"here\")":"thevalue"}],"id":"123455"}';
$json = json_decode($json_string, true);
$questions = $json['questions'];
for($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
foreach($question as $key => $value) {
echo "Question: " . $key . "\n";
echo "Answer:" . $value . "\n";
}
}
$json_string='{“somthing”:“12345”,“questions”:[{“Question Here about something.”也有类似这样的引号\“Here\”:“thevalue”}],“id”:“123455”};
$json=json_解码($json_字符串,true);
$questions=$json['questions'];
对于($i=0;$i$value的问题){
回显“问题:.$key.\n”;
回显“应答:“.$value.”\n;
}
}
我相信问题->{“这里有问题…”
应该可以让您访问它。或者传递true
作为json_decode
的第二个参数,并在数组中访问它$questions[“这里有问题…”
我相信questions->{“这里有问题…”
应该可以让您访问它。或者传递true
作为json_decode
的第二个参数,并在数组中访问它$questions[“这里有问题…”
我相信questions->{“这里有问题…”
应该可以让您访问它。或者传递true
作为json_decode
的第二个参数,并在数组中访问它$questions[“这里有问题…”
我相信questions->{“这里有问题…”
应该可以让您访问它。或者传递json\u decode
的第二个参数true
,并在数组$questions[“此处有问题…”]中访问它