note 92753 deleted from function.implode by danbrown

From: Date: Fri, 07 Aug 2009 14:45:44 +0000
Subject: note 92753 deleted from function.implode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159189@lists.php.net to get a copy of this message
Note Submitter: ravenswd at gmail dot com ---- Turned my previous post into a function: <?php function ensure (&$a, $filler = '') { // given: array $a with numerical keys // return: $a with keys sorted numerically and any gaps filled-in $highest = max(array_keys($a)); for ($i = 0; $i <= $highest; ++$i): if (! isset($a[$i])): $a[$i] = $filler; endif; endfor; ksort ($a); } // end function ensure // usage: // ensure($foo); // ensure($bar, 0); ?>

« previous php.notes (#159189) next »