note 100234 deleted from function.range by danbrown

From: Date: Sun, 03 Oct 2010 22:28:45 +0000
Subject: note 100234 deleted from function.range by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172921@lists.php.net to get a copy of this message
Note Submitter: amxm at ya dot ru ---- input: array (0,1,2,3,11,12,13,14); output: 0-3,11-14 /** * Range View * * Maxim Arnautov 2010 */ function range_view($array){ $start=false; foreach ($array as $key => $h){ if ($start===false) { $start=$h; continue; } if ($start!==false AND $h==($array[$key+1]-1)) continue; elseif ($start!==false) { $hw.="{$start}-{$h},"; $start=false; } } $hw = trim($hw,','); return $hw; }

« previous php.notes (#172921) next »