|
-
Jul 20th, 2010, 10:51 PM
#1
Thread Starter
Frenzied Member
loading text file into array help
Hi all; It's been quite a few years since I've visited these forums! Surprised my login was correct on the first attempt..
I haven't done any sort of programming in years, but just got into a little bit of PHP for fun over the past month or so. I have an issue right now and I don't know if I'm going about this right or not, and I found another way to accomplish this but it would involve just using someone else's code which I'd rather try and keep going in the direction I've already gone with this.
OK: I have multiple files involved here. an html form for user input, and then a php file for grabbing the info and putting it all in a text file on new lines. My issue now is for my 2nd php file I want to grab the text back from the text file and put it into an array.
Heres an example of what my text file would look like:
last name
first name
password
email
phone
experience level
last name
first name
password
email
phone
experience level
As you can see it will just keep repeating like above, depending on how many entries were on the form.
So what I'm trying to do is grab the first 6 lines(before they reset to the next user in the file) and place into a multidimensional array. then the next 6 lines..etc
I want to be able to then display this information into a table. (which I haven't gotten to this part yet..but doubt ill have too much trouble here)
PHP Code:
$myUser = array("Green" => array(
"first name" => "Tom",
"password" => "Ha",
"email" => "[email protected]",
"phone" => "1234567",
"experience" => "Advanced"
this is sort of the format I'd go about for the array I'm thinking. I've tried several things with counters etc, but if anyone has an example or easier way to grab my text file and put into a multidimensional array without knowing how much data will be in the file.
I've used the following to grab the data from each line and place it into an array, but just not a multiD array.
PHP Code:
$File = file_get_contents("users.txt");
$myArray = explode("\n", $File);
Any help or insight would be appreciated!
Thanks in advance.
~
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|