我知道这里有很多类似的问题,我想我已经全部阅读过了。我的问题是我试图遍历数组列表并从每个数组中获取一个值。阵列已由第三方设置,我无权配置接收它们的方式。这是我到目前为止所拥有的:
for ($i = 0; $i < $length; $i++) {
// Both of these work and return the value I need
echo $post->related_credits_0_related_show[0];
echo "{$post->related_credits_0_related_show[0]}"
// But none of these do, and I need to loop through a handful of arrays
echo "{$post->related_credits_{$i}_related_show[0]}";
echo "{$post->related_credits_${i}_related_show[0]}";
echo "{$post->related_credits_{${i}}_related_show[0]}";
echo "{$post->related_credits_".$i."_related_show[0]}";
}
我已经尝试了很多(很多!)更多我不会包括在内的组合。我也尝试将 $i 转换为字符串。有一段时间我一直在反对这个。
提前感谢您的帮助。