Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum size of an array in PHP?

Tags:

arrays

php

We like to store database values in array. But we do not know the maximum size of an array which is allowed in PHP?

like image 815
Amruta Avatar asked Jul 28 '11 09:07

Amruta


People also ask

What is the maximum size of an array?

The maximum allowable array size is 65,536 bytes (64K). Reduce the array size to 65,536 bytes or less. The size is calculated as (number of elements) * (size of each element in bytes).

How do you find the maximum and minimum of an array in PHP?

$min = min($numbers); $max = max($numbers); Option 2. (Only if you don't have PHP 5.5 or better) The same as option 1, but to pluck the values, use array_map : $numbers = array_map(function($details) { return $details['Weight']; }, $array);

What is the maximum size of an integer array?

Since the index of the array is int, the approximate index value can be 2^31 – 1. Based on this approximation, we can say that the array can theoretically hold 2,147,483,647 elements.

How do you find the largest number in an array in PHP?

The max() function of PHP is used to find the numerically maximum value in an array or the numerically maximum value of several specified values. The max() function can take an array or several numbers as an argument and return the numerically maximum value among the passed parameters.


2 Answers

There is no max on the limit of an array. There is a limit on the amount of memory your script can use. This can be changed in the 'memory_limit' in your php.ini configuration.

like image 154
Tim Avatar answered Oct 09 '22 10:10

Tim


Array size is limited only by amount of memory your server has. If your array gets too big, you will get "out of memory" error.

like image 44
Silver Light Avatar answered Oct 09 '22 08:10

Silver Light