我想从表中的JSON代码中检索长数据,它看起来像
{"def":{"short":"the first, in place, time, order or rank (specifically, a firstfruit)","long":["first, beginning, best, chief",["beginning","first","chief","choice part"]]},"deriv":"from the same as H7218","pronun":{"ipa":"reʔˈʃɪi̯t̪","ipa_mod":"ʁeʔˈʃiːt","sbl":"rēʾšît","dic":"ray-SHEET","dic_mod":"ray-SHEET"}}
{"def":{"short":"the sky (as aloft; the dual perhaps alluding to the visible arch in which the clouds move, as well as to the higher ether where the celestial bodies revolve)","long":["heaven, heavens, sky",["visible heavens, sky",["as abode of the stars","as the visible universe, the sky, atmosphere, etc"],"Heaven (as the abode of God)"]]},"deriv":"dual of an unused singular שָׁמֶה; from an unused root meaning to be lofty","pronun":{"ipa":"ʃɔː.mɑˈjɪm","ipa_mod":"ʃɑː.mɑˈjim","sbl":"šāmayim","dic":"shaw-ma-YIM","dic_mod":"sha-ma-YEEM"}}更多的数据,我做了这个:
$data_result = json_decode($data, true);
$long_definition_1 = $data_result['def']['long'][0];
$compter_long = count($data_result['def']['long'][1]);
for($i=0; $i<$compter_long; $i++)
{
$long_definition_1 .= ', ';
$long_definition_1 .= $data_result['def']['long'][1][$i];
}
echo $long_definition_1;它适用于第一行并显示:
Long Def 1 : first, beginning, best, chief, beginning, first, chief, choice part 但是对于第二行和其他行,它发送给我这个错误。
Notice: Array to string conversion in E:\A - A - SITES ET SERVER\EasyPHP-DevServer-13.1VC9\data\localweb\BIBLES SQL BIBLEFORGE\BibleForgeDB-master\BibleForgeDB-master\brouillons.php on line 164我找了好几天到处都找不到解决办法。我将非常感谢你的帮助。谢谢
发布于 2014-01-15 19:42:07
因为在第二个数组中,也有一个数组
['def']['long'][1][1]因此,它不能将数组放入字符串中。

这是一个非常有用的网站,很容易看到json http://jsonviewer.stack.hu/中的内容。
https://stackoverflow.com/questions/21146332
复制相似问题