note 29779 modified in function.array by vrana

From: Date: Tue, 17 Aug 2004 13:56:51 +0000
Subject: note 29779 modified in function.array by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79928@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. <?php $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! --was-- 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://php.net/manual/en/function.array.php

« previous php.notes (#79928) next »