好吧,我不确定我能不能把这个写好,但我会努力的。从后端脚本我真的不能改变太多。我有一个非常大的多维数组被吐出到 UI 中,其中主数组中的数组不包含正常的 0-n 索引方案,并且由于它们的关联,它们是在后端生成的。所以我有例如一块看起来像的多维数组
Array(
[0] = Array(
[stuff] = 'something'
[morestuff] = 'other'
[info] = array(
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
)
),
[1] = Array(
[stuff] = 'something'
[morestuff] = 'other'
[info] = array(
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
[generated_id_based_on_assication] = array(
[id] = '12345t'
[desc] = 'blah blah'
[url] = '/some/where'
)
)
)
)
我不知道数组的最佳表示。但是为了举例,因为我不能发布实际数据本身,我需要做的是为[info]
数组找到每个,这样我就可以从每个数组generated_id_based_on_assication
中提取数据。generated_id_based_on_assication
但是看到它不是一个 0-n 索引我不知道如何获取“generated_id_based_on_assication”部分,以便我可以处理其中的数据,因为通过 foreach 或任何类型的循环运行它确实不是一个选项数组中的特定数组。有人有建议吗?如果我能够通过循环运行它,我可以做到,但这就是我被绊倒的地方,我不能,因为这些数据列在表中,并且该数组的所有内容都是基于每行的。