Php 在类中找不到字段

Php 在类中找不到字段,php,function,class,model,Php,Function,Class,Model,我试图将用户可用性与函数中的组相匹配 问题是我不知道如何将模型(getAllAvailability)调用到数组中,以便对照组表检查它。我可能只是做错了 这是我能得到的最接近的结果,但在网上: foreach($this->availability as $key => $value) 找不到可用性:( 这是我的全部代码: public function find() { /**Find groups that are not closed and s

我试图将用户可用性与函数中的组相匹配

问题是我不知道如何将模型(getAllAvailability)调用到数组中,以便对照组表检查它。我可能只是做错了

这是我能得到的最接近的结果,但在网上:

foreach($this->availability as $key => $value) 
找不到可用性:(

这是我的全部代码:

public function find()
    {


        /**Find groups that are not closed and send to group_find page */
        array('availability' => AvailabilityModel::getAllAvailability());
        foreach($this->availability as $key => $value) {
            GroupModel::getMatchingGroup($value->hour);

            if ($value->hour == 1600){

                /**Redirect::to('group_add user to group and check for max group size'); */
                Redirect::to('group/group_find');
            }
var\u dump()之后


@SaidKholov-哇,我明白了。我不知道我在这方面工作了多久,直到我请求了一些帮助,我才能够找到答案。我在考虑你的var_转储,我意识到我正在尝试将结果生成一个数组,而它们已经是一个数组了。
因此,摆脱生成数组行,我:

/**Find groups that are not closed and send to group_find page */
        foreach(NewguyModel::getAllAvailability() as $key => $value) {
            GroupModel::getMatchingGroup($value->hour);
        }if ($value->hour == 1600){

                /**Redirect::to('group_add user to group and check for max group size'); */
                Redirect::to('note');
            }

你没有向我们展示足够的代码,但是你在
array('availability'=>AvailabilityModel::getAllAvailability());
上创建了一个数组,但是你没有将它分配给一个变量。这可能是你的问题吗?
var\u dump(AvailabilityModel::getAllAvailability());
看起来像什么?当我var\u dump时,我得到数组(3){[0](1)2个“可用性方面的id”=>字符串(1)8“8”字符串(1)“8”字符串(1)8“[“日”天”==>字符串(1)1“8”8“[“天”==>字符串(1)字符串(1)1)天”=>字符串(1)1)1“1”8“1”8”[1)天”=>字符串(1)1)1)1“1”1)1”1“1”1”1”1“1”1”1”[1”1”1“1”[1”1(1”1”1”[1)1”1”[1”1”[1”1”1(1)(1)(1)(1)(1)1)(1)(1)(1)(1)1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)1)1)1(一)“2”[“availability\u id”]=>string(2)“10”[“day”]=>string(1)“3”[“hour”]=>string(4)“1600”}@AndreasIndahl-我尝试将其分配给一个变量,但无法在函数中定义一个变量……我完全是个新手。
/**Find groups that are not closed and send to group_find page */
        foreach(NewguyModel::getAllAvailability() as $key => $value) {
            GroupModel::getMatchingGroup($value->hour);
        }if ($value->hour == 1600){

                /**Redirect::to('group_add user to group and check for max group size'); */
                Redirect::to('note');
            }