Michdd Posted March 2, 2009 Share Posted March 2, 2009 If I have 2 variables, $x and $y and I want to make a mutli-dimensional array that matches those. For example say $x = 5; and $y = 6; then I want my contents of the array to look like this: [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0] All filled with 0s but with the right specs.. Link to comment https://forums.phpfreaks.com/topic/147502-creating-an-array-with-certain-specs/ Share on other sites More sharing options...
br0ken Posted March 2, 2009 Share Posted March 2, 2009 <?php $r = 6; // Rows $c = 5; // Columns for($i = 0; $i < $r; $i++) for($j = 0; $j < $c; $j++) $buff[$i][$j] = 0; ?> I haven't tested this code but that should do the trick. Link to comment https://forums.phpfreaks.com/topic/147502-creating-an-array-with-certain-specs/#findComment-774298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.