You are here: Re: multidimensional array declaration in php « PHP Programming Language « IT news, forums, messages
Re: multidimensional array declaration in php

Posted by Jerry Stuckle on 07/15/06 19:31

vito wrote:
>>>> $a[$i] = array();
>>>
>>>Is the above declaration legitimate?
>>
>>as long as $a is defined as an array, yes.
>>
>
>
> $array = array();
>
> for ($k = 0; $k < 10000; $k++)
> $array[$k] = array();
>
> for ($j = 0; $j < 10000; $j++)
> for ($k = 0; $k < 3; $k++)
> $array[$j][$k] = 0;
>
> How to initialize?
>
> $array[$i][1] = $array[$i][1] . $line;
> PHP Notice: Undefined offset: 2700 in array.php on line 24
>
>

Well, in this case you're trying to initialize 10,000 * 10,000 arrays,
each with an integer. On a 32 bit system that's something like
400,000,000 bytes (close to 400 mb) of storage plus the overhead of the
arrays themselves. Probably a bit more than you have available - the
default is around 8M.

Why would you ever try to initialize this much memory (in either PHP or
C/C++) anyway?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация