I'm not sure if something similar already exists, but I needed it so I made it:<?php/* Performs a pitagoric sum of the elements in $arr The pitagoric sum of a set of values is the square root of the sum of the sqare power of each value. So, for a, b, c it's sqrt(a^2 + b^2 + c^2) */ /* If any element of $arr is an array itself, the array_sum will be used. Alternatively, the values could be used by recursion. Returns the integer part (floor) */function array_pitag_sum($arr) { if(is_array($arr) {$ret = 0; foreach($arr as $i) { if(is_array($i)) {$s = array_sum($i);$ret += $s*$s; } else {$ret += $i*$i; } } return floor(sqrt($ret)); } else { return $arr; } }?>

Here is how you can multiply two arrays in the form of matrixes using a bit of matrix algebra (M*M).By calling the function multiplyMatrix, you will be multiplying two sparse matrixes (zeros need not be included in the array for the operation to be performed).