Hello:
I am doing a presentation in about 2 hours and part of it needs to read in a CSV text file into PHP... can someone tell me the quickest way to do this?
Thanks many times over for your help on this!
Mike
Reading in a CSV File
Moderator: General Moderators
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
Thanks Feyd
Yes, I saw the manual entry but I am not very clear on how to get this... the file is very simple...
I need an actual code snippit that reads in my file... here is the file contents right now...
This actually is what is in the text file and I am working on the script it will generate it with commas between artist song album.
The fgetcsv() function page is over my experience though I am not sure if I just copy one of those codes in it will work?
I need an actual code snippit that reads in my file... here is the file contents right now...
Code: Select all
Currently playing song: "Everywhere" by Michelle Branch on <i>The Spirit Room</i>.The fgetcsv() function page is over my experience though I am not sure if I just copy one of those codes in it will work?
fgetcsv will copy the file into an array, each line an element in the array. then you could explode, or write a couple regexs to get out the information that you want...
in your example, it would produce an array like this
Array (
[0] => Currently playing song: "Everywhere" by Michelle Branch on <i>The Spirit Room</i>.
}
so whatever name you chose for the array, this line would be $array[0]
in your example, it would produce an array like this
Array (
[0] => Currently playing song: "Everywhere" by Michelle Branch on <i>The Spirit Room</i>.
}
so whatever name you chose for the array, this line would be $array[0]
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.