Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to parse a CSV file into an array in PHP

1 Answer

0 votes
$csv = array_map('str_getcsv', file('d:\\test.csv'));

echo "<pre>"; print_r($csv); echo "</pre>";


/*
run:
    
Array
(
    [0] => Array
        (
            [0] => csv_post_title
            [1] => csv_post_post
            [2] => csv_post_excerpt
            [3] => csv_post_categories
            [4] => csv_post_tags
            [5] => csv_post_date
            [6] => csv_post_author
            [7] => csv_post_slug
            [8] => csv_ctax_art
            [9] => csv_ctax_country
            [10] => my_custom1
        )

    [1] => Array
        (
            [0] => Vincent Van Gogh
            [1] => Vincent Willem van Gogh post-Impressionist painter
            [2] => Vincent Willem van Gogh was a Dutch post-Impressionist painter
            [3] => Art, CSV Importer
            [4] => van gogh, dutch, painter
            [5] => June 1, 2010
            [6] => alice
            [7] => Van-gogh-one
            [8] => Painting, post-impressionism
            [9] => Netherlands,France
            [10] => 53
        )

    [2] => Array
        (
            [0] => Claude Monet
    ...
      
*/

 



answered Jul 18, 2016 by avibootz

Related questions

1 answer 199 views
3 answers 246 views
246 views asked Dec 9, 2015 by avibootz
1 answer 167 views
167 views asked Feb 16, 2021 by avibootz
2 answers 215 views
215 views asked Dec 17, 2015 by avibootz
1 answer 144 views
144 views asked Feb 16, 2021 by avibootz
...