Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $test = array();
- // populate array
- for($i=0; $i<5; $i++)
- {
- for ($j=0; $j < 5; $j++) {
- $test[$i][$j] = rand(0, 10);
- }
- }
- echo '<hr/>';
- displayArray($test);
- echo '<hr/>';
- //x = rows
- //y = columns
- // for each row
- for ($i = 0; $i<5; $i++)
- {
- if($i == 5-1) // if this is the LAST row
- continue; // skip this iteration
- $x = $i; // initialize X to this row
- $y = $x+1; // initialise Y to the row numer + offset 1
- // display value
- echo '$test['.$x.']['.$y.'] = '.$test[$x][$x+1] .'<br/>';
- }
Add Comment
Please, Sign In to add comment