Page 1 of 1

function using itself

Posted: Mon Oct 06, 2008 8:55 am
by m2babaey
Hi
can i use a function this way:

Code: Select all

 
function determinant($mtrix, $n){
 
if ($n=1) {
// do something
}
else
{
return aclcaulationssss*determinant($mtrix, $n-1);
}
}
 

Re: function using itself

Posted: Mon Oct 06, 2008 8:56 am
by onion2k
Yes. It's called recursion. Be careful you don't write something that can end up in an infinite loop.