Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用空格访问json结果_Php_Json - Fatal编程技术网

Php 使用空格访问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

我从一个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 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[“此处有问题…”]中访问它