Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:39:03+00:00 2026-05-23T10:39:03+00:00

I have this csv file with ; separated fields. I want to be able

  • 0

I have this csv file with ; separated fields. I want to be able to read the file and put the values into session variables to insert them into a mySQL database.

I have this code for reading de file and create the array. And now I want to create the session variables to pass them to the insert.php file.

Content of my csv file:

“S11PBMS02.14045″;16.93;5;NULL;NULL;1;NULL;217.64;1;NULL;NULL;1;NULL;1;”52X45-CAR10/1XCAR10/1″;0;0;0;”140″;”PB Mini Stripe 02″;46;#;”S11PBMS02.14045″;”PB Mini Stripe 02″;”Vichy Estofos”;”PBMS02″;”140″;”52X45-CAR10/1XCAR10/1″;”090″;217.64;330.63;233.73;330.63;”C147″;”02(Fawn)”;41012;41144;;;;;;;;;;;;;;;”*”;41012;;;;;;;

My code:

<?php
$arrCSV = array();
if (($handle = fopen("style.dai", "r")) !==FALSE) {
$key = 0;
while (($data = fgetcsv($handle, 0, ";")) !==FALSE) {
   $c = count($data);
   for ($x=0;$x<$c;$x++) {
   $arrCSV[$key][$x] = $data[$x];
   }
   $key++;
} 
fclose($handle);
} 
echo "<pre>";
echo print_r($arrCSV);
echo "</pre>";
?> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:39:03+00:00Added an answer on May 23, 2026 at 10:39 am

    Its pretty much the same:

    <?php
    session_start();
    $arrCSV = array();
    if (($handle = fopen("style.dai", "r")) !==FALSE) {
    $key = 0;
    while (($data = fgetcsv($handle, 0, ";")) !==FALSE) {
       $c = count($data);
       for ($x=0;$x<$c;$x++) {
       $arrCSV[$key][$x] = $data[$x];
       $_SESSION['values'][$x] = $data[$x];
       }
       $key++;
    } 
    fclose($handle);
    } 
    echo "<pre>";
    echo print_r($arrCSV);
    echo print_r($_SESSION['values']);
    echo "</pre>";
    ?> 
    

    You could also just set the session value to be the same as $arrCSV

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a csv file : 1|1.25 2|23.56 3|58.99 I want to put this
I have a csv importroutine which imports my CSV values into Sitecore. After this
I have a simple csv file with around 20K+ values separated by commas. When
I have a CSV file containing data. I want to load it into a
I have a CSV (comma separated values) file that contains student information. The column
Okay, so I have this CSV file of products and all the products have
I have a CSV file formatted just like this: name,color,tasty,qty apple,red,true,3 orange,orange,false,4 pear,greenish-yellowish,true,1 As
Ok, I have a csv file like this: 14 ; 1234,56 ; 10203 ;
I have CSV data loaded into a multidimensional array. In this way each row
I have CSV file with sample data in this form : 220 30 255

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.