|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2021-11-18 15:42 UTC] cmb@php.net
 
-Status: Open
+Status: Suspended
  [2021-11-18 15:42 UTC] cmb@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 13:00:01 2025 UTC | 
Description: ------------ This feature would allow one to define a value to be used for creating multiple array indexes (think of it as an array "fill" with a tad more flexibility). The "flexibility" is that rather than using a numerical starting index value and a length parameter, this new syntax would set the same value for each value in a 1-dimensional array of scalars (used as keys). This syntax is essentially a more convenient/concise way of doing something like: foreach($array_of_keys as $key) $the_array[$key] = $value_for_keys; with the added bonus that it would work both when defining an entire array or just modifying an existing array. These two use case scenarios are modeled below as Use Case #1 and #2, respectively. Test script: --------------- <?php /* ---------------------- Use Case #1 ---------------------- */ // set/clear appropriate bits at intialization/definition $binary = array( range( 0, 0) => 1, range( 1, 1) => 0, range( 2, 3) => 1, range( 4, 11) => 0, range(12, 15) => 1 ); /* ---------------------- Use Case #2 ---------------------- */ // initialize array representation of 16-bit binary number to 0 $binary = array_fill(0, 16, 0); // set appropriate bits $binary[range( 0, 0)] = 1; $binary[range( 2, 3)] = 1; $binary[range(12, 15)] = 0; ?>