原因为被foreach的数组可能为空,则会报错,只需做好容错即可,例如 if ( !empty( $arr ) ) { foreach ( $arr as $k => $v ) { } } 转载于:https://www.cnblogs.com/Basu/p/8603626.html