Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wordpress致命错误:无法在中使用stdClass类型的对象作为数组_Php_Wordpress - Fatal编程技术网

Php wordpress致命错误:无法在中使用stdClass类型的对象作为数组

Php wordpress致命错误:无法在中使用stdClass类型的对象作为数组,php,wordpress,Php,Wordpress,我一直收到这个错误,但我很确定我的代码没有问题: 编辑:错误还显示注意:未定义属性:stdClass::$0 in <?php foreach ($testoppervlaktes as $oppervlakte): ?> <?php foreach($testtypes as $key => $value){ if($oppervlakte[

我一直收到这个错误,但我很确定我的代码没有问题: 编辑:错误还显示注意:未定义属性:stdClass::$0 in

<?php foreach ($testoppervlaktes as $oppervlakte): ?>
                    <?php 
                    foreach($testtypes as $key => $value){
                        if($oppervlakte[$value->$key == true]){                       

                        } else {               

                        }
                    }
                    ?>
                    <option data-4="" data-5="" data-6="" data-7="" value="<?php echo $oppervlakte->name ?>"<?php if(isset($_GET['oppervlakte']) && $_GET['oppervlakte'] == $oppervlakte): ?> selected<?php endif; ?>><?php echo $oppervlakte->name; ?></option>
我想检查[“6”]和[“4”]是否为真,但可能有更多或更少的字段为真或假,可以是[“4”][“5”][“6”][“7”]全部为假/真或混合

在前面的循环中,我将数据设置为true或false

foreach($testoppervlaktes as $key => $value){
        if($value->term_id == $huidigvastgoedoppervlakteid){
            $testoppervlaktes[$key]->$huidigtypeid = true;
        }
    }

你的情况应该是这样的:

if($oppervlakte[$value->{$key}] == true){                       
   // your stuff
} else {               
   // your stuff    
}

我已经试过了,但还是有同样的错误,unfortunately@FrankLucas:$key具有数字键。。。你不能用它。那你有什么想法吗?@FrankLucas:foreach($testopperlaktes as$opperlakte):?>print\u r($opperlakte);你想从这个数组中得到哪一个索引?很抱歉,但你的确切意思是什么?这行
if($opperlakte[$value->$key==true]){
似乎有点错误,除非你知道你在做什么,也许它应该是这样的:
if($opperlakte[$value->$key]==true){
foreach($testopperlaktes as$opperlakte):>ok也打印出来($testtypes);检查您是否获得相同的索引?
if($oppervlakte[$value->{$key}] == true){                       
   // your stuff
} else {               
   // your stuff    
}