警告:非法字符串偏移'顺序'

时间:2015-02-19 14:44:47

标签: php wordpress

您好我在假日网站的wordpress过滤页面中收到以下消息:

警告:第916行/home/jefmaher/public_html/wp-content/themes/thevacationrental/functions.php中的非法字符串偏移'顺序'

警告:第917行/home/jefmaher/public_html/wp-content/themes/thevacationrental/functions.php中的非法字符串偏移'顺序'

这是php的片段

$i = 9999;
foreach( $options['customdatas'] as $key => $data ) {
    if( empty( $data['order'] ) ) {
        $options['customdatas'][$key]['order'] = $i;
        $data['order'] = $i;
    }

我是php的新手,需要一些建议

谢谢

杰夫

1 个答案:

答案 0 :(得分:1)

“非法字符串偏移”消息表示$ data不是数组,而是字符串,至少是foreach的一种情况。一种解决方法是检查$ data是否实际上是一个数组。

if (is_array($data)) ;//