Maximum Size for PHP Array

Is there a maximum size that a PHP array can be?  I purchased a product to parse Excel files recently.  This product reads the whole excel file into a PHP array.  However, the excel file I am trying to parse has 18,000 rows and about 20 columns.  For some reason it just crashes in the middle of it.

I have increase the amount of memory for PHP and also the execution time so those shouldn't be a problem.

So I just want to know if there is a limit on the amount of indexes an array in PHP can have.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I dont know how much you can store in a php array but why would you need to store that much data anyway?  Its not very practical to store large amounts of data in an array (not that large anyway), if the data is being stored to be processed, then i'd rethink the way in which you process the data, maybe prcoess it as its being retrieved from the spreadsheet, rather than storing it in an array and then processing it.
I've used arrays with 60000 rows, so that's not the problem.  Odds are it's a memory issue.  Can you figure out the largest file you can use without a crash?

As Karl says, you may want to find some way to read and parse the file a few lines at a time.
leobaz2Author Commented:
Well, I what I did was I kept deleting rows until I found the limit as to when the parsing worked.  I was able to find that actual character that was making it crash.  If I remove the last character, it works, if I put a character in it fails.  Therefore, I was assuming it was a memory problem.  But then I doubled the memory with the character in there and it still failed.

Is there anything special I have to do to have the memory update to be used?  I restarted apache after changing php.ini.  I also made sure that the php was configured with the "enable-memory-limit" option.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Interesting.  What's the maximum file size that works?

You also might contact whoever sold the product to you and see what they say.
leobaz2Author Commented:
I am not sure what the max file size is now since I am at work and my other stuff is at home.  I believe it breaks with around a 6-8 MB file and works with a 5MB and lower.

The company I bought this product from was of no help at all.  I opened 2 issues with them and they have no idea and gave up.  Now they are ignoring me.  They mentioned that Microsoft "might" change the way they save the Excel sheet for files larger than a certain size.

The problem is that this Excel parser doesn't use COM since it is supported on Unix platforms also.  So this is pure binary processing which makes it much harder to debug and fix.

I create an 18000 x 20 Excel sheet of random 15-digit numbers.  File size was 6,955,520 bytes.  I deleted a row and file size jumped to 6,958,592 - an increase of 3072 bytes.  I deleted 8 more rows and the size went down by either 0 or 512 bytes for each line.  So it's possible that at either 18000 rows or somewhere around 6.6MB, they change something.

I couldn't find any documentation from MS regarding such a change, but a Google search did reveal several people having similar problems with files of a similar size.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leobaz2Author Commented:
Thanks a lot for the invenstigation.  I will look more at this tonight to see what is going on.

That's probably "fast save" working against you.  MS has the bright idea of not changing the file when you change it, but rather keeping it and appending the changes on.  Which means it reconstructs it all when the file is loaded.

You said when you removed a single character that it could process it, even when the file was much larger but without that character?  Which character?
And is there any off chance you could convince your users to just "Save As..." a CSV file?  That would probably solve your headaches.
arantius:  I don't doubt your superior knowledge of Excel, but if the "fast save" is the case, I wonder why it gets smaller as I delete more lines?  It's only the first deletion where it gets bigger, then progressively smaller as I delete more lines from the same file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.