Skip to content

Instantly share code, notes, and snippets.

@jfreites
Created November 18, 2016 16:26
Show Gist options
  • Save jfreites/89141ff4ebface7a7925eeebdfa5b459 to your computer and use it in GitHub Desktop.
Save jfreites/89141ff4ebface7a7925eeebdfa5b459 to your computer and use it in GitHub Desktop.
Imprimir todas las diagonales de una matriz
for ($i = 0; $i < $rows; $i++) {
for ($j = 0; $j < $cols; $j++) {
if ($i == $j) {
$res .= $arr[$i][$j].'/n';
}
if ($i == ($cols - $j - 1)) {
$res .= $arr[$i][$j];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment