Hi
I have a text file named email.txt which has the following contents
test@test.com
a@x.com
zooman@deeply.b ored.org
b@x.com
guess.me@where. ami.net
testmore@test.c om
I want only the domain part of the listed email ids separately. The code which I tried is as follows
but I am getting some warning message as shown below
Warning: file(C: mpp\htdocs\prac tice2ile conceptiles\ema il.txt) [function.file]: failed to open stream: Invalid argument in C:\xampp\htdocs \practice2\file concept\file_fu nction.php on line 16
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs \practice2\file concept\file_fu nction.php on line 8
Plz help me out to solve this problem
I have a text file named email.txt which has the following contents
test@test.com
a@x.com
zooman@deeply.b ored.org
b@x.com
guess.me@where. ami.net
testmore@test.c om
I want only the domain part of the listed email ids separately. The code which I tried is as follows
Code:
<?php
function getUniqueDomains($list)
{
$domains = array();
foreach($list as $l)
{
$arr = explode("@", $l);
$domains = trim($arr[1]);
}
return array_unique($domains);
}
$filecontents = file("C:\xampp\htdocs\practice2\file concept\files\email.txt");
$returnArray = getUniqueDomains($filecontents);
foreach($returnArray as $d)
{
print "$d, ";
}
?>
Warning: file(C: mpp\htdocs\prac tice2ile conceptiles\ema il.txt) [function.file]: failed to open stream: Invalid argument in C:\xampp\htdocs \practice2\file concept\file_fu nction.php on line 16
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs \practice2\file concept\file_fu nction.php on line 8
Plz help me out to solve this problem
Comment