PHP code example of mazedlx / median

1. Go to this page and download the library: Download mazedlx/median library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mazedlx / median example snippets


$arrayOfValues = [1, 2, 5, 1000, 7]
$m = new Median($arrayOfValues);

$avg = $m->average();
// $avg == 203

$median = $m->median();
// $median == 5