function using itself

Discussion in 'PHP' started by promotingspace.net, Oct 6, 2008.

  1. #1
    Hi
    can i use a function this way:
    
    function determinant($mtrix, $n){
    
    if ($n=1) {
    // do something
    }
    else
    {
    return aclcaulationssss*determinant($mtrix, $n-1);
    }
    }
    
    PHP:

     
    promotingspace.net, Oct 6, 2008 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    YES, you can, it is called recurssion.

    Anyway, you could try using it instead of asking us. You would save some time wouldn't you? :)
     
    Greg Carnegie, Oct 6, 2008 IP