[ create a new paste ] login | about

Link: http://codepad.org/mRdBN5MK    [ raw code | output | fork ]

PHP, pasted on Mar 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

    function max2() {
       $max = -PHP_INT_MAX;
       foreach(func_get_args() as $arg) {
          if ($arg > $max) {
              $max = $arg;
          }
       }
       return $max;
    }

var_dump(max2(-7, -5, -1));


Output:
1
int(-1)


Create a new paste based on this one


Comments: