note 109642 added to function.range

From: Date: Fri, 03 Aug 2012 22:59:10 +0000
Subject: note 109642 added to function.range
Groups: php.notes 
Request: Send a blank email to php-notes+get-189915@lists.php.net to get a copy of this message
if you need zero padding, string prefixes or any other masks, then a simple combination of array_map, inline functions and sprintf is your friend. <?php $a = array_map(function($n) { return sprintf('sample_%03d', $n); }, range(50, 59) ); print_r($a); ?> Will result: Array ( [0] => sample_050 [1] => sample_051 [2] => sample_052 [3] => sample_053 [4] => sample_054 [5] => sample_055 [6] => sample_056 [7] => sample_057 [8] => sample_058 [9] => sample_059 ) ---- Server IP: 69.147.83.197 Probable Submitter: 209.213.206.108 ---- Manual Page -- http://www.php.net/manual/en/function.range.php Edit -- https://master.php.net/note/edit/109642 Del: integrated -- https://master.php.net/note/delete/109642/integrated Del: useless -- https://master.php.net/note/delete/109642/useless Del: bad code -- https://master.php.net/note/delete/109642/bad+code Del: spam -- https://master.php.net/note/delete/109642/spam Del: non-english -- https://master.php.net/note/delete/109642/non-english Del: in docs -- https://master.php.net/note/delete/109642/in+docs Del: other reasons-- https://master.php.net/note/delete/109642 Reject -- https://master.php.net/note/reject/109642 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189915) next »