note 29779 added to function.array
| From: | marcel at labor-club dot de | Date: | Tue, 25 Feb 2003 01:58:34 +0000 |
| Subject: | note 29779 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44466@lists.php.net to get a copy of this message | ||
i tried to find a way to create BIG multidimensional-arrays. but the notes below only show the usage
of it, or the creation of small arrays like $matrix=array('birne', 'apfel',
'beere');
for an online game, i use a big array (50x80) elements.
it's no fun, to write the declaration of it in the ordinary way.
here's my solution, to create an 2d-array, filled for example with raising numbers.
$matrix=array();
$sx=30;
$sy=40;
$i=1;
for ($y=0; $y<$sy; $y++)
{
array_push($matrix,array());
for ($x=0; $x<$sx; $x++)
{
array_push($matrix[$y],array());
$matrix[$x][$y]=$i;
$i++;
}
}
if there is a better way, plz send an email. i always want to learn more php!
--
http://www.php.net/manual/en/function.array.php
http://master.php.net/manage/user-notes.php?action=edit+29779
http://master.php.net/manage/user-notes.php?action=delete+29779
http://master.php.net/manage/user-notes.php?action=reject+29779