Reply to Re: multidimensional array declaration in php

Your name:

Reply:


Posted by Chung Leong on 07/17/06 17:06

Markus Ernst wrote:
> As Arrays are passed by value and not by reference, you can define the
> new array outside the for loop.
>
> $myArray = array();
> $newArray = array(0, 0, 0);
> for ($i=0; $i<10000; $i++) {
> $myArray[] = $newArray;
> }
>
> or
>
> $myArray = array();
> for ($i=0; $i<10000; $i++) {
> $myArray[] = array(0, 0, 0);
> }
>
> I don't know which is faster.
> Anyway this does not explain the undefined offset notice, and it does
> not really answer why one should do this at all :-)

The first one is faster, since a single array is created vs. 10000. It
also uses a whole lot less memory.

[Back to original 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

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