I would like to use a textarea in html form to get the delimited data
for example:
The simple data is like the following
testA@testa.com peter USA
testB@testB.com Tony USA
testC@testC.com tom USA
testA@testa.com peter USA
testA@.com peter USA
The problems are:
-
How to check where is each line ends? (\n)?
-
How to do duplication checking (only for email)? (if 3 data each row, get 1,4,7,11…data, and array_unique?)
-
Should i restrict the deliminator symbol or i do something to check automatically?
-
What If space is deliminator , but at same time my other data eg. is using space e.g. Tony Hanks ?
Thank you for any kind of help
First I would split string by line ends:
To check the delimiter, explode first line by all delimiters that are possible and check array count.
After that use proper delimiter with str-getcsv on raw data: http://www.php.net/manual/en/function.str-getcsv.php
In that case you need to use quotes. Excel also could not handle this without quotes.
Create array where keys are emails. Iterate through your parsed csv and check if key isset already or not.