Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $test = array();
- // initialize the array with random values
- for($i=0; $i<5; $i++)
- {
- for ($j=0; $j < 5; $j++) {
- $test[$i][$j] = rand(0, 10);
- }
- }
- displayArray($test); // custom function I wrote to display the array in a HTML table
- //x = rows, y = columns
- for ($x = 0; $x<5; $x++) // loop over each row
- {
- if($x == 5-1) // if this is the LAST row
- continue; // skip this iteration
- $y = $x+1; // initialise Y to the row numer + offset 1
- // i.e. this will point to the cells on the RIGHT of the diagonal
- // display value
- echo '$test['.$x.']['.$y.'] = '.$test[$x][$y] .'<br/>';
- }
Add Comment
Please, Sign In to add comment