我知道这里有很多类似的问题,我想我已经把它们都读了.我的问题是我试图遍历一个数组列表并从每个数组中获取一个值.阵列已由第三方设置,我无权配置我接收它们的方式.这是我到目前为止所拥有的:
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]}";
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多(很多!)更多我不会包含的组合.我也尝试将$ i转换为字符串.我一直在反对这个问题.
提前感谢您的帮助.