Using .csv file to populate an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
otherslost
Forum Newbie
Posts: 1
Joined: Sat Jan 17, 2009 12:23 am

Using .csv file to populate an array?

Post by otherslost »

This is my first post here & hopefully it's not a stupid one.

I have a mysql db that takes data from a c-shell script and I built a web interface to access the data in a very clean manner. Everything works how it's supposed to and the layout is exactly what I was after.

Now I want to be able to pass multiple search terms to the page and have it find and display all the entries on one page.

I was thinking that I would need to upload the text/csv file to the server then parse each line of the file and put them into an array that I can then write a foreach loop to find all of the entries I am searching for.

I have anywhere from 50-100+ items to search for at a time and it would be great to have a way that I can automate the process without having to input each search term individually.

Does anyone have any ideas how I should go about doing this?

Thanks in advance for any help anone can offer.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Using .csv file to populate an array?

Post by Burrito »

fgetcsv() is going to be your easiest solution.

Just add items to your array on each iteration of the loop.
Post Reply