note 56168 added to function.array-fill

From: Date: Thu, 25 Aug 2005 15:41:39 +0000
Subject: note 56168 added to function.array-fill
Groups: php.notes 
Request: Send a blank email to php-notes+get-94186@lists.php.net to get a copy of this message
array_fill doesn't appear to work nicely if there are more than one element at a level. It redimensions the array. I had an array that looked like: $wk_array = array(1 => array(1=>0,2=>0), 2 => array(1=>0,2=>0), 3 => array(1=>0,2=>0), 4 => array(1=>0,2=>0)); I tried to zero the 1st element at the 2nd level using: $wk_array = array_fill(1,4,array_fill(1,1,0)); I wanted to accumulate totals in the 2nd element. A print_r after the array_fill showed that the array looked like array(1 => array(1=>0),2 => array(1=>0), etc.) ---- Manual Page -- http://www.php.net/manual/en/function.array-fill.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56168 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56168&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56168&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94186) next »