I need some help with a piece of code. I'm working on the customers list of my club, I can extract email address and print them on the screen, I just can't write them into a txt. Here's the code:
<?php if ( $_POST ){
function extract_emails($str)
{
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
$xurl = $_POST['testo'];// THERE IS AN INPUT FIELD
$doc = new DOMDocument();
@$doc->loadHTMLFile($xurl);
$xpath = new DOMXpath($doc);
$wpage = $xpath->query('//body[@*]');
print_r(extract_emails($wpage->item(0)->nodeValue));
$scrivi=fopen("emails.txt","a");
fwrite($scrivi,NEED SOMETHING HERE."\n");
fclose($scrivi);
}
?>
Everytime and anything I try the only output I found in the file is "Array".