note 33865 added to function.array
| From: | darthjarkon at hotmail dot com | Date: | Wed, 09 Jul 2003 16:09:43 +0000 |
| Subject: | note 33865 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51799@lists.php.net to get a copy of this message | ||
I found a slightly better way to create large 2d arrays:
// this will simply output a 2d array-- it isn't very robust but it
//suits my needs here
function display_all($array){
echo "<table><tr>";
foreach($array as $spot){
echo "<td align='center' width= '20'>";
foreach($spot as $spotdeux){
echo "<br>".$spotdeux;
}
}
echo "</tr> </table>";
}
//this actually creates the array and puts the value 0 in all
// locations. the $xax and $yax can be upped or
//downed to create a larger or smaller array
function creater_array(){
$ar=Array();
$xax=5;
$yax=5;
$i=1;
for ($y=0; $y<$yax; $y++)
{
array_push($ar,array());
for ($x=0; $x<$xax; $x++)
{
array_push($ar[$y],"0");
}
}
return $ar;
}
$b = creater_array();
display_all($b);
----
Manual Page -- http://www.php.net/manual/en/function.array.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33865
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33865&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33865&report=yes