Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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 Can';我不知道如何在Foreach循环中创建一个数组,以便使用Codeigniter框架吐出电子邮件列表_Php_Arrays_Codeigniter_Foreach - Fatal编程技术网

Php Can';我不知道如何在Foreach循环中创建一个数组,以便使用Codeigniter框架吐出电子邮件列表

Php Can';我不知道如何在Foreach循环中创建一个数组,以便使用Codeigniter框架吐出电子邮件列表,php,arrays,codeigniter,foreach,Php,Arrays,Codeigniter,Foreach,型号: 控制器: public function get_app(){ $this->db->select('email'); $this->db->from('app'); $query = $this->db->get(); return $query->result(); } 我需要创建一个从db检索的电子邮件列表,以添加到mail函数以发送通知,但我很难使

型号:

控制器:

public function get_app(){
        $this->db->select('email');
        $this->db->from('app');
        $query = $this->db->get();
        return $query->result();        

    }

我需要创建一个从db检索的电子邮件列表,以添加到mail函数以发送通知,但我很难使用foreach循环收集电子邮件,将该列表包含在一个数组中。

这里对您的代码进行了一些修改

                $this->load->model('po_model');
                $this->po_model->po_insert($data);
                $emails = $this->po_model->get_app();


                foreach($emails as $email){

                $app = array('app_email'=> $email->email);
                }


                //SEND NOTIFICATION
                $to = $app['app_email'];

上面的代码在数组中添加所有电子邮件,当您想要发送时,使用代码将它们内爆并发送给所有人。如果你想给每个人发送一封电子邮件,只需将你的邮件代码放入循环并发送邮件。

这里对你的代码进行了一些修改

                $this->load->model('po_model');
                $this->po_model->po_insert($data);
                $emails = $this->po_model->get_app();


                foreach($emails as $email){

                $app = array('app_email'=> $email->email);
                }


                //SEND NOTIFICATION
                $to = $app['app_email'];

上面的代码在数组中添加所有电子邮件,当您想要发送时,使用代码将它们内爆并发送给所有人。如果你想向每个人发送一封电子邮件,只需将你的邮件代码放入循环并发送邮件。

太棒了!我会试试这个,很有魅力,谢谢你很高兴知道我的解决方案对你有帮助。太棒了!我会试试这个,很有魅力,谢谢你很高兴知道我的解决方案对您有所帮助。