微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP-消息:在CodeIgniter中为foreach提供了无效的参数

我在应用Codeigniter的过程中遇到了几个问题-创建了一个函数

function searchUnivtab() {
        $country = $this->input->post('countryKey');
        $state = $this->input->post('stateKey');
        $level = $this->input->post('level');
        $degType = $this->input->post('degType');       
        $country = str_replace('%20', ' ', $country);
        $state = str_replace('%20', ' ', $state);
        $degType = explode('~', $degType);
        $data = @$this->get->getSearchedUniversityTab($country, $state, $level, $degType[1]);
        $html = '';
        $i = 0;
        foreach($data as $d)
        {
            $html .= '<option value="'.$d['name'].'">'.$d['name'].'</option>';
        }
        echo $html; die;
    }

错误为:遇到PHP错误严重性:警告消息:为foreach()提供无效的参数,行号:270,位于foreach行

与上述代码有关的任何帮助吗?

解决方法:

在下面的行中删除@以查看是否产生任何错误
所以更换

$data = @$this->get->getSearchedUniversityTab($country, $state, $level, $degType[1]);

$data = $this->get->getSearchedUniversityTab($country, $state, $level, $degType[1]);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐