Результат тот же
<?php
function actionIndex() {
$url = 'https://otvet.mail.ru/question/8449918';
$str = file_get_contents($url, false, $context);
preg_match_all("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $str, $matches);
$urls[] = $matches[0];
$model = new \app\models\Sites;
$model->url = $url;
$model->insert();
$modelMail = new \app\models\Email;
$modelMail->site_id = $model->site_id;
var_dump($model);
foreach ($matches[0] as $value) {
var_dump($value);
$modelMail->email_text = $value;
$modelMail->insert();
}
return $this->render('index', [
'matches' => $matches,
]);
}
что выдает?