title: How to calculate Diagonal difference in PHP?
body: <p>I have a <strong>N*N</strong> Matrix.Now i want to know the diagonal difference of this Matrix.What will be the best approach of this solution?</p>
  
  <p>I am trying with given approach:</p>
  
  <p>Such as it is <strong>3*3</strong> Matrix say it is:</p>
  
  <pre><code>11 15 85
  66 72 21
  14 21 47
  </code></pre>
  
  <p>the diagonal simple formula will be:</p>
  
  <pre><code>firstD= (11+72+47) = 130
  secondD = (85+72+14)= 171
  diagonalDiff = |firstD - secondD| = |130-171| = 41
  </code></pre>
  
  <p>If I count every row such as first to find out <code>firstD</code> (First row's first value + Sec row's Sec value + Third row's third value+..).This is my thinking.
  Can anyone tell me best approaches?</p>