<?php $file = file('mail.txt'); foreach ($file as $mail) { if (strpos($mail, '@rambler.ru') !== false) { echo $mail; } }