【发布时间】:2013-01-27 05:06:22
【问题描述】:
这就是我所拥有的
foreach ( $post_formats as $format ) {
if ( $options['show_post_formats'][$format] == 0 ) {
$format = 'post-format-' . $format;
array_push( $hide, $format );
}
}
它工作正常......但在我调试时给了我一个未定义的索引:错误,因为它希望 $format 的值用引号引起来。我该如何正确地做到这一点?
【问题讨论】:
-
我们需要查看更多代码
-
好的,但是 $format 是调试器遇到的问题,因为它期望值在引号中
-
正如@MathieuImbert 所说,更多来源会很有用,但您可以使用isset检查索引是否存在
-
@byronyasgur 您的数组中不存在特定的
$format,您应该使用劳伦斯的答案。 -
认为我可能对问题所在有错误的认识
标签: php arrays debugging multidimensional-array indexing