Napravio sam PHP skriptu čija je funkcija generisanje E-mail adresa na osnovu liste najčešćih imena i prezime.
Lista sa imenima se nalazi u text fajlu usa-firstnames.txt, a lista sa prezimenima se nalazi u text fajlu usa-surnames.txt.
Skripta treba da napravi sve moguće kombinacije imena i prezimena, da doda svakoj toj kombinaciji "@" i na kraju E-mail provajder. I da ih snimi opet u text fajl - emaillist_finished.txt.
tj. ako je ovo lista sa imenima:
michael
william
david
a ovo lista sa prezimenima:
brown
jones
skripta treba da napravi ovo i da snimi u text fajl - emaillist_finished.txt.
michaelbrown@gmail.com
michaeljones@gmail.com
williambrown@gmail.com
williamjones@gmail.com
davidbrown@gmail.com
davidjones@gmail.com
Ovo je skripta:
PHP kôd:
<?php
$emailservice = "gmail.com";
// reading firstnamelist
$firstnamelistfile = fopen("usa-firstnames.txt", "r");
$firstnamelistarray = array();
while (!feof($firstnamelistfile))
{
$line_of_text_firstnamelist .= fgets($firstnamelistfile);
$firstnamelistarray = explode("\n", $line_of_text_firstnamelist);
$line_of_text=trim($line_of_text_firstnamelist);
}
$number_of_firstnames = count($firstnamelistarray);
fclose($firstnamelistfile);
// reading lastnamelist
$lastnamelistfile = fopen("usa-surnames.txt", "r");
$lastnamelistarray = array();
while (!feof($lastnamelistfile))
{
$line_of_text .= fgets($lastnamelistfile);
$lastnamelistarray = explode("\n", $line_of_text);
$line_of_text=trim($line_of_text);
}
$number_of_lastnames = count($lastnamelistarray);
fclose($lastnamelistfile);
// creating emaillist
$writeemaillist = fopen("emaillist_finished.txt", "w");
for ( $f = 0; $f<$number_of_firstnames; $f++ )
{
for ( $l = 0; $l<$number_of_lastnames; $l++ )
{
$createdemailaddress = $firstnamelistarray[$f].$lastnamelistarray[$l]."@".$emailservice;
$outputstring = $createdemailaddress."\n";
fwrite($writeemaillist, $outputstring);
}
}
fclose($writeemaillist);
?>
E problem je u tome što mi ne ispisuje pravilno E-mail adrese u taj tekstualni fajl - emaillist_finished.txt.
Namjesto da ih ispiše ovako:
michaelmichael@gmail.com
michaelwilliam@gmail.com
michaeldavid@gmail.com
ona ih ispisuje ovako:
michael
michael
@gmail.com
michael
william
@gmail.com
michael
david
@gmail.com
I ne mogu da otkrijem gdje je problem??? Bio bih zahvalan da mi neko pomogne...