finished a script earlier today that scans a table in a db and extracts the email address from it, which is then exported to a csv file.
now im combining the second half of the script except this time the information is coming from a csv, then performing the same operations and exporting the email address to a different csv.
Problem is that the imported csv has csv line break codes placed in ( "\n"). WHen i open the exported file i see weird line breaks in excel and quotes ("") in notepad. str_replace doesn't seem to remove them. Here is the code. Any thoughts?
<html>
<head>
<title>Data Manipulation</title>
</head>
<body>
<h2>Email Address Extract</h2>
<?php
$valid_Emails=array();
$findme = '@';
$line_break = "\n";
$handle = @fopen("./import.csv", "r+");
if ($handle) {
while (!feof($handle)) {
$address = fgets($handle);
$words= explode(' ', $address);
foreach ($words as $value)
{
if(strpos($value,$findme) === false) {
} else {
array_push($valid_Emails, $value);
}
}
}
}
$export = fopen("./export.csv", "w+");
fputcsv($export, $valid_Emails, $line_break);
fclose($handle);
fclose($export);
?>
<text>Results have been saved to export.csv</text><br />
<input type=button onClick="location.href='./export.csv'" value='Download'>
</body>
</html>