php - Write file after extract data -
i need piece of code. i'm working on customers list of club, can extract email address , print them on screen, can't write them txt. here's 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 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 here."\n"); fclose($scrivi); } ?>
everytime , try output found in file "array".
[solved] @jdo, i've solved way:
$mail = (extract_emails($wpage->item(0)->nodevalue)); $result = var_export($mail, true); echo $result ; $scrivi=fopen("emails.txt","a"); fwrite($scrivi,$result."\n"); fclose($scrivi);
Comments
Post a Comment