【发布时间】:2016-10-13 06:21:46
【问题描述】:
我有这样的json数据
{
"Sentence": {
"Subject": {
"Name": "Tom"
},
"Verb": {
"verb1": "is",
"verb2": "eating"
},
"Object": {
"Fruit": "Banana"
}
},
"Sentence2": {
"Subject": {
"Name": "Mary"
},
"Verb": {
"verb1": "eats",
},
"Object": {
"Fruit": "Apple"
}
}
}
然后,我通过
将其转换为数组$array = json_decode($json,true);
我得到了数组,
array(2) {
["Sentence"]=>
array(3) {
["Subject"]=>
array(1) {
["Name"]=>
string(3) "Tom"
}
["Verb"]=>
array(2) {
["verb1"]=>
string(2) "is"
["verb2"]=>
string(6) "eating"
}
....
现在,我只想得到结果, 喜欢
"Tom is eating banana"
"Mary eats Apple".
两个句子的结构不一样,怎么办?
【问题讨论】: