Guest User

Untitled

a guest
Jun 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. $test = array();
  2.  
  3. // populate array
  4. for($i=0; $i<5; $i++)
  5. {
  6.     for ($j=0; $j < 5; $j++) {
  7.         $test[$i][$j] = rand(0, 10);
  8.     }
  9. }
  10.  
  11. echo '<hr/>';
  12. displayArray($test);
  13. echo '<hr/>';
  14.  
  15. //x = rows
  16. //y = columns
  17.  
  18.  
  19. // for each row
  20. for ($i = 0; $i<5; $i++)
  21. {
  22.     if($i == 5-1) // if this is the LAST row
  23.         continue; // skip this iteration
  24.  
  25.     $x = $i; // initialize X to this row
  26.     $y = $x+1; // initialise Y to the row numer + offset 1
  27.  
  28.     // display value
  29.     echo '$test['.$x.']['.$y.'] = '.$test[$x][$x+1] .'<br/>';
  30. }
Add Comment
Please, Sign In to add comment