note 115793 deleted from function.array-fill by salathe
| From: | salathe@php.net | Date: | Fri, 21 Nov 2014 15:01:38 +0000 |
| Subject: | note 115793 deleted from function.array-fill by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200999@lists.php.net to get a copy of this message | ||
Note Submitter: rn at alpha9marketing dot com
----
Before PHP 5.6, array_fill emits a warning if the argument $num is zero. This is a bit annoying if
you compute a desired array length. As a workaround, one can use array_pad, which is less strict.
I.e.
<?php
$desiredLength = 0;
// $noWorky = array_fill(0, $desiredLength, "a");
$worky = array_pad(array(), $desiredLength, "a");
?>