note 114938 added to function.range

From: Date: Wed, 30 Apr 2014 15:09:24 +0000
Subject: note 114938 added to function.range
Groups: php.notes 
Request: Send a blank email to php-notes+get-199378@lists.php.net to get a copy of this message
I needed a function, that creates a letter range with arbitrary length. You specify via the $length parameter, how many entries you need. Logic is analog to the logic of the column-titles in a calc-sheet. <?php /** * create a letter range with arbitrary length * @param int $length * @return array */ function createLetterRange($length) { $range = array(); $letters = range('A', 'Z'); for($i=0; $i<$length; $i++) { $position = $i*26; foreach($letters as $ii => $letter) { $position++; if($position <= $length) $range[] = ($position > 26 ? $range[$i-1] : '').$letter; } } return $range; } ?> ---- Server IP: 49.212.134.217 Probable Submitter: 46.237.201.86 ---- Manual Page -- http://php.net/manual/en/function.range.php Edit -- https://master.php.net/note/edit/114938 Del: integrated -- https://master.php.net/note/delete/114938/integrated Del: useless -- https://master.php.net/note/delete/114938/useless Del: bad code -- https://master.php.net/note/delete/114938/bad+code Del: spam -- https://master.php.net/note/delete/114938/spam Del: non-english -- https://master.php.net/note/delete/114938/non-english Del: in docs -- https://master.php.net/note/delete/114938/in+docs Del: other reasons-- https://master.php.net/note/delete/114938 Reject -- https://master.php.net/note/reject/114938 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199378) next »