Re: Middle Number

From: Date: Sat, 07 Dec 2002 03:59:40 +0000
Subject: Re: Middle Number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127358@lists.php.net to get a copy of this message
At 09:45 PM 12/6/02 -0500, Stephen wrote:
How can you find the meadian (or middle number) of a list of numbers? If there is an even amount of numbers, how would I still find it?
load the list into an array, in numeric order... then: $List = array( 1,2,3,4,5,6 ); $Middle = ( count( $List ) - 1 ) / 2; $median = ( $List[ floor( $Middle ) ] + $List[ ceil( $Middle ) ] ) / 2;

« previous php.general (#127358) next »