I have been trying to use this code to print 10 columns and 10 rows. I get one or the other, can some one help me figure out how to get both. With the <br /> I get 10 rows, with out it I get 10 columns. Will an IF statement help me? thanks $array = array('1' => "O", '2'=>'O', '3'=> '$', '4'=>'M', '5' => '^'); function populateRoom ($myArray) { print "$myArray <br />"; } for($row = 1; $row <= 10; $row++) { for($c = 1; $c <= 10; $c++) { $randomNumber = rand(1,5); $myArray = $array[$randomNumber]; print $myArray; populateRoom ($myArray); }}
all br does is give you a line break. you'd be better putting it into a table (or use css, but I think that's a step too far at this stage) $array = array('1' => "O", '2'=>'O', '3'=> '$', '4'=>'M', '5' => '^'); function populateRoom ($str) { print "<td>{$str}</td>"; } print "<table>"; for($row = 0; $row < 10; $row++) { print "<tr>"; for($col = 0; $col < 10; $col++) { $randomNumber = rand(1,5); $val = $array[$randomNumber]; populateRoom ($val); } print "</tr>"; } print "</table>"; PHP: Untested, but should work.