note 115793 added to function.array-fill

From: Date: Wed, 24 Sep 2014 16:47:47 +0000
Subject: note 115793 added to function.array-fill
Groups: php.notes 
Request: Send a blank email to php-notes+get-200515@lists.php.net to get a copy of this message
PHP emits a warning if array_fill's $num argument 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"); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 195.14.234.228 ---- Manual Page -- http://php.net/manual/en/function.array-fill.php Edit -- https://master.php.net/note/edit/115793 Del: integrated -- https://master.php.net/note/delete/115793/integrated Del: useless -- https://master.php.net/note/delete/115793/useless Del: bad code -- https://master.php.net/note/delete/115793/bad+code Del: spam -- https://master.php.net/note/delete/115793/spam Del: non-english -- https://master.php.net/note/delete/115793/non-english Del: in docs -- https://master.php.net/note/delete/115793/in+docs Del: other reasons-- https://master.php.net/note/delete/115793 Reject -- https://master.php.net/note/reject/115793 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200515) next »