1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: PHP - From CSV to Multidimensional Array

Discussion in 'Web Design & Development' started by cc64, Jul 14, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. cc64

    cc64 Thread Starter

    Joined:
    Dec 21, 2007
    Messages:
    153
    Hello TSG!

    I have a CSV file with 5 attributes and 6 rows. I want to throw that structure into a two dimensional array. I have a found a few topics around the web that don't seem to work. (Which made me question why I went anywhere BUT TSG.) Ideas?

    Thanks for any help.
    Curtis
     
  2. cc64

    cc64 Thread Starter

    Joined:
    Dec 21, 2007
    Messages:
    153
    I will mark this solved, but for those curious, here is how I solved it:

    Code:
    if (($handle = fopen("slider.csv", "r")) !== FALSE)
               {
                    while(($data = fgetcsv($handle,1000,",")) !==FALSE)
                    {
                         array_push($slideattrs, array($data[0], $data[1], $data[2], $data[3], $data[4]));
                    {
               {
    
    $slideattrs was declared array() at the beginning.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1007380