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

  • SEARCH
  • Home
  • 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 8963231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:18:50+00:00 2026-06-15T16:18:50+00:00

I am trying to upload a CSV file and get it’s contents into an

  • 0

I am trying to upload a CSV file and get it’s contents into an array, but I am getting this an error: (Multiples of this error on each line after 10)

Notice: Undefined offset: 1 in C:\xampp\htdocs\amazon\upload_file.php on line 10

Below is a sample of my code:

if ($handle = file_get_contents($_FILES["file"]["tmp_name"])) {

$data = array();

while ($csv = array(file_get_contents($_FILES["file"]["tmp_name"]))) {
    $data = array(
        'order-id' => $csv[0],
        'order-item-id' => $csv[1], //This is line 10.
        'purchase-date' => $csv[2],
        'payments-date' => $csv[3],
  • 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-06-15T16:18:51+00:00Added an answer on June 15, 2026 at 4:18 pm

    file() opens puts each as an array element. fgetcsv() and its family of functions are very useful when dealing with csv files.

    Your code array(file_get_contents($_FILES["file"]["tmp_name"])) will only ever have one element because file_get_contents returns a string.

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

Sidebar

Related Questions

I'm trying to upload this CSV file onto my table in pgsql, but I'm
I'm trying to upload a rails app to dotcloud. I'm getting this error: PG::Error
I'm trying to upload a 95 GB CSV file into a MySQL database (MySQL
I am trying to upload a .csv file and than save each row to
I can't really read PHP but I'm trying to upload a csv file in
I'm getting an error when trying to upload a .csv to my sql server
I'm trying to upload csv file to index. When I do I'm getting an
I'm currently trying to upload a csv file to a database through simple html
I am trying to upload a single .csv file in ASP.NET MVC. In my
I'm trying to upload images to a php file, everything works, but sometimes when

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.