I have a jsfiddle and have edited it to include sessions for passing values that the user inputs. Currently it does regex checking for phone numbers and parses the value in textbox into an array.
It uses localStorage to save the numbers in the list..
Currently it takes numbers into that textbox and adds them to the list. What I want to do is I want name and number to all be in that one textbox and both to be added into the list together WITH error checking. Now the real problem is that once the array passes the list over once you hit submit, I want to read those array values all into a textfile line by line for each array item.
So for example,
if a user enters 903456346346 kergfer kerger, due to the invalid number it should give error and tell them to redo…
but if their lists looks like:
2195679876 John Polski (array item 1)
2195395676 Cara Polski (array item 2)
2195679346 Jennifer Ray (array item 3)
2195456756 Matt Hardy (array item 4)
then they submit, it should make the textfile look like this:
2195679876 John Polski
2195395676 Cara Polski
2195679346 Jennifer Ray
2195456756 Matt Hardy
I know how to put all the text in a file into one line but thats not how I want it. I want it sorted like the above. I would really liek to use a db for this but I have never used one and they seem kind of complicated…Any tutorial I found starts off with prior knowledge of command-line so I am stuck and decided to either use sessions with session life set to 4 years OR use plain ol text file. The below is what I have and it puts everything into one line..
$myFile = "testFile.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
You could very easily use fgetcsv() and fputcsv() to save the data into a .csv file. If you don’t want to use a database. It would be structured, have one entry per line and still be readable.