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 8993239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:08:58+00:00 2026-06-15T23:08:58+00:00

I have 2 array from data.csv How can I use while loop to print

  • 0

I have 2 array from data.csv
How can I use while loop to print out both array
I can only print out 1st array and it keep loop same array.

        $file = fopen("data.csv","r");

        while(!feof($file)){
          print_r(fgetcsv($file));
          }

        fclose($file);

////////////////////////////////////////////////////////////////
    $file=fgetcsv($file);
    $num=0;

    while($num<4){
        echo $file[0] . $file[1] . $file[2] . $file[3] . "<br/>";
        $num++;
        }

         ////////////////////////////////////////////////////////////  
            Array
            (
            [0] => a
            [1] => b
            [2] => c
            [3] => d
            )
            Array
            (
            [0] => e
            [1] => f
            [2] => g
            [3] => h
            )
  • 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-15T23:08:59+00:00Added an answer on June 15, 2026 at 11:08 pm

    Try this to do your task

    $source = fopen('zipcode.csv', 'r') or die("Problem open file");
        while (($data = fgetcsv($source, 1000, ",")) !== FALSE)
        {
            $col1 = $data[0];
            $col2 = $data[1];
            $col3 = $data[2];
    
    
            echo $col1 . ' ' . $col2 . ' ' . $col3 . '<br />';
    
        }
        fclose($source);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data in a numpy array (read from a .csv file). The relevant
I have following CSV data: 10,11,12.34 I can parse this using CSV from the
I have a variable that contains an array from form data, seen below: $option1
I have some array data returned from an ajax call consisting of an image
I have one main array which is the returned data from a MySQL query
I have a model that I'm trying to retrieve an array of data from,
I have taken the data from database into array now I want it to
I have an accordion that binds data for each item from an array. I
I have a problem related to an array data which fetched from an external
I have a csv file uploaded and data read into an array .The valid

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.