I've got a csv with a list of emails in a single column with no header.
Very simply, they're like this:
[email protected]
[email protected]
[email protected]
...etc
And there are 30k of them.
I need to convert this list of emails in to a simple array using PHP.
I understand the concept of fgetcsv() but as we know it reads a row at a time, so what I end up with is several arrays by iterating through my csv instead of one.
I need this:
Array
(
[0] => [email protected]
[1] => [email protected]
[2] => [email protected]
)
What I'm getting is this:
Array
(
[0] => [email protected]
)
Array
(
[0] => [email protected]
)
Array
(
[0] => [email protected]
)
Here's my code:
if (($file = fopen("emails.csv", "r")) !== FALSE) {
while (($data = fgetcsv($file)) !== FALSE) {
// do stuff
}
echo '<pre>';
print_r($data);
echo '</pre>';
echo '<br/>';
fclose($file);
}
Is there a simple way of simply converting a whole CSV column in to an array using PHP? I've been doing my research but have yet to find a solution.