Web Hosting Talk







View Full Version : PHP CSV with different titles from same CSV file


horizon
06-21-2009, 01:45 AM
Ok, this is quite a complicated request so I'll try to make as simple as possible.

Now, I have a csv file let's say like this:

id[title1],name[title2],model[title1]
0,test,00-11-22

As you can see, I have two different titles in the CSV as the fields name.

What I'd like to do is to create a PHP loop that would allow to show each of these titles including their values proportionally with 2 different arrays (one for the titles, one for the values but set by title quantity).

Now, I don't need the CSV manipulation but simply the right PHP loop that would accomplish this type of fetching result.

Is there anyone that would know how to do this ?

mwatkins
06-21-2009, 02:56 AM
It would help to clarify your objective if you were to provide a couple of sample data rows (not just the one) and a mock up of the output you expect.

horizon
06-21-2009, 10:45 AM
The data rows is not the main objective. The main objective is to be able to chunk the fields with its value by each different arrays for each different categories of each rows as shown in the example. In other words, I want to be able to split the rows and values for each categorized names under each different arrays separately.

mwatkins
06-22-2009, 07:55 PM
Again, it would greatly help in communicating your objective if you were to layout some data and a mockup of the different arrays output so that we can see the relation to the field names. It can never hurt communication to see a sample of the end result.

I have guesses about what you mean but I hate to operate on guesses.

horizon
06-22-2009, 10:58 PM
This issue has now been resolved. The preg_split function seem to fit right in.