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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:38:34+00:00 2026-06-04T05:38:34+00:00

I have a list of csv files which I need php to convert to

  • 0

I have a list of csv files which I need php to convert to one large multidimensional array, testing with just 2 php exceeds the max execution time when conduction the second conversion.

1st conversion being from csv to numerical multidimensional array

2nd conversion being from numerical multidimensional array to string and numerical multidimensional array, which is where php produces the error.

My code is as follows:

function parse($data) {
    $i = 0;
    while (isset($data[$i])) {
      $row = 0;
      while (isset($data[$i][$row])) {
        switch ($row) {
          case 0:
            //General Item details
            $fOv = 0;
            while (isset($data[$i][$row][$fOv])) {
              $array['Item'][$i][$data[$i][row][$fOv]] = $data[$i][$row + 1][$fOv];
              $fOv++; // THIS IS THE PLACE OF THE ERROR
            }
            break;
          case 2:
            //General Transaction details
            $fOv = 0;
            while (isset($data[$i][$row][$fOv])) {
              $array['Transaction'][$i][$data[$i][$row][$fOv]] = $data[$i][$row + 1][$fOv];
              $fOv++;
            }
            break;
          case 4:
            //Buyer details
            $fOv = 0;
            while (isset($data[$i][$row][$fOv])) {
              $array['Transaction']['Buyer'][$i][$data[$i][$row][$fOv]] = $data[$i][$row + 1][$fOv];
              $fOv++;
            }
            break;
          case 6:
            //Shipping details
            $fOv = 0;
            while (isset($data[$i][$row][$fOv])) {
              $array['Transaction']['Shipping'][$i][$data[$i][$row][$fOv]] = $data[$i][$row + 1][$fOv];
              $fOv++;
            }
            break;
          case 8:
            //Status details
            $fOv = 0;
            while (isset($data[$i][$row][$fOv])) {
              $array['Transaction']['Status'][$i][$data[$i][$row][$fOv]] = $data[$i][$row + 1][$fOv];
              $fOv++;
            }
            break;
        }
      $row + 2;
      }
      $i++;
    }
    return $array;
  }

This is how the numerical array looks like:

array (
  0 => array (
    0 => array (
      0 => 'field 1', 1 => 'field 2', 2 => 'field 3' //continues to field 17
    )
    1 => array (
      0 => 'value 1', 1 => 'value 2', 2 => 'value 3' //continues to value 17
      //these values are for the fields in array[0][0]
    )
    2 => array ( //same as array[0][0] )
    3 => array ( //same as array[0][1], values for array[0][2] )
    4 => array ( //same as array[0][0] )
    5 => array ( //same as array[0][1], values for array[0][4] )
    6 => array ( //same as array[0][0] )
    7 => array ( //same as array[0][1], values for array[0][6] )
    8 => array ( //same as array[0][0] )
    9 => array ( //same as array[0][1], values for array[0][8] )
  )
  1 => array (
    //same structure as array[0], different details
  )
)

what I’m trying to get for the string and numerical array:

array (
  0 => array (
    'Item' => array (
      0 => array ( 
        'field 1' => 'value 1'
        'field 2' => 'value 2'
        //continues to field 17
      )
    )
    'Transaction' => array (
       0 => array (
        'field n' => 'value n' //repeated until field 17
        'Buyer' => array (
          //same as above in array[0]['Item'][0]
        )
        'Shipping' => array (
          //same as above in array[0]['Item'][0]
        )
        'Status' => array (
          //same as above in array[0]['Item'][0]
        )
      )
    )
  )
  1 => array (
    //same structure as array[0], different values
  )
)

Any help is greatly appreciated, thanks in advance.

EDIT:
I don’t want to increase the max execution time, the script should take less than 30 seconds, the same as the working script I have which stores the data in the csv files in the first place.

  • 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-04T05:38:35+00:00Added an answer on June 4, 2026 at 5:38 am

    The quick and dirty approach:

    ini_set('max_execution_time', 0);
    

    Although be aware that if your script goes into an infinite loop, it’ll never end 🙂 More likely is that removing the time limit will cause you to hit a memory limit, so you may do well to run this via the command line to avoid crashing apache.

    Edit:
    Try altering your code not to use variable names like $iii as this is very hard to read. You may find that this alone will make the solution obvious.

    Edit:
    $row + 2;
    ought to be
    $row += 2;

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

Sidebar

Related Questions

I have a large CSV file containing a list of stores, in which one
Need to process large csv files with php. Working with fgetcsv and performance seems
I have list of files which contain particular patterns, but those files have been
I have a list of csv files ( file1, file2, ... ) that have
I have a CSV file with many rows in which I need to update/replace
I have a large number of csv files that I want to read into
I have around 100 csv files with common headers, which i want to merge.
i have one csv file which contains library group and it's data... group consider
I have a list of (many) employees in Excel/csv who take sick days, listed
I have a list of string that I am writing out to a CSV

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.