Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php median

function median($a) { 
    sort($a);
    $c = count($a);
    $m = floor(($c-1)/2);
    return ($c % 2) ? $a[$m] : (($a[$m]+$a[$m+1])/2);
}
echo median([1,6,4,2,4,6,10,12,19]); //6
Comment

PREVIOUS NEXT
Code Example
Php :: print value in laravel console 
Php :: xampp check php version 
Php :: integer division in php 
Php :: get message validator failed laravel 
Php :: php validate name 
Php :: symfony call another controller 
Php :: how to use sseders in laravel 
Php :: laravel gigapay create employee 
Php :: randomstring php 
Php :: laravel abort_if 
Php :: preg_match number only in php 
Php :: laravel pass parameter to resource collection 
Php :: laravel modules slowdown 
Php :: how to add cutom menu option in wordpress 
Php :: check php version mac 
Php :: php remove wordpress shortcodes 
Php :: php sql last 10 rows 
Php :: kill laravel server 
Php :: php first 20 words 
Php :: php return loading message 
Php :: verificare esistenza file in php 
Php :: Turning a StdClass object into an array 
Php :: php redirect to page 
Php :: get_posts term 
Php :: get all errors view laravel 
Php :: laravel 8 selecet the 2nd to the last record 
Php :: laravel active nav 
Php :: mysql server has gone away php 
Php :: download speed limit php 
Php :: php call protected function from child class 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =