警告:非法的字符串偏移量';订单';在里面


Warning: Illegal string offset 'order' in

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

警告:第916行上/home/jefmaher/public_html/wp-content/themes/thevacationrent/functions.php中的非法字符串偏移量"order"

警告:第917行上/home/jefmaher/public_html/wp-content/themes/thevacationrent/functions.php中的非法字符串偏移量"order"

这是php 的片段

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

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

感谢

Jeff

"非法字符串偏移量"消息表示$data不是数组,而是字符串,至少在foreach的一种情况下是这样。一种修复方法是检查$data是否实际上是一个数组。

if (is_array($data)) ;//