note 100652 added to function.max

From: Date: Thu, 28 Oct 2010 10:00:55 +0000
Subject: note 100652 added to function.max
Groups: php.notes 
Request: Send a blank email to php-notes+get-173547@lists.php.net to get a copy of this message
If you want to test whether x lies within two bounds: static function isInRange($x, $y1, $y2) { return( ($x >= min($y1, $y2)) && ($x <= max($y1, $y2)) ); } called by: class::isInRange(10,12,2); or $this->isInRange(10,12,2); or (drop static) isInRange(10,12,2); simple test function: static function unit_isInRange() { $output = array(); $inputlist[] = array(10, 12, 2, true); $inputlist[] = array(13, 12, 2, false); $inputlist[] = array(2, -2, 2, true); $inputlist[] = array(2, -8, -2, false); foreach($inputlist as $input) { $output[] = array( 'input' => array($input[0], $input[1], $input[2]), 'output' => self::isInRange($input[0],$input[1],$input[2]), 'expected' => $input[3], ); } return($output); } ---- Server IP: 69.147.83.197 Probable Submitter: 82.71.10.13 ---- Manual Page -- http://www.php.net/manual/en/function.max.php Edit -- https://master.php.net/note/edit/100652 Del: integrated -- https://master.php.net/note/delete/100652/integrated Del: useless -- https://master.php.net/note/delete/100652/useless Del: bad code -- https://master.php.net/note/delete/100652/bad+code Del: spam -- https://master.php.net/note/delete/100652/spam Del: non-english -- https://master.php.net/note/delete/100652/non-english Del: in docs -- https://master.php.net/note/delete/100652/in+docs Del: other reasons-- https://master.php.net/note/delete/100652 Reject -- https://master.php.net/note/reject/100652 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173547) next »