faqts : Computers : Programming : Languages : PHP : kms : General : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 13 people (85%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

If I define $array[10000], will PHP use/reserve memory for $array[0] - [9999]?

Apr 11th, 2002 05:39
Mike Ford, Joost Cassee,


No.

PHP only creates array elements when you actually assign a value to 
them.  This is because of the associative nature of PHP arrays.

As a corollary, you can also un-assign individual elements:

   unset($arr[99]);