|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-24 11:13 UTC] jani@php.net
-Status: Open
+Status: Bogus
-Package: Feature/Change Request
+Package: *General Issues
[2010-11-24 11:13 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 14:00:02 2025 UTC |
Description: ------------ Based on the rise of web based applications, it is common to have applications that allow a user to insert an indefinite number of rows of data (such as an invoice, contact list). It would be great to see array_map take an array of keys as the first argument, also, so that it does the same thing as if the first argument was null, but uses the first array as the keys of the maped arrays, much like array_combine being called on each maped array after. This recycles an already existing function to do something I thought it would already be able to do without the callback. PHP DATA GENERATED FROM HTML FORM OF AN INVOICE: $_POST["Invoice"] = array( "Description" => array( "A widget", "A gadget" ), "Price" => array( '$1.00', '$3.00' ), "Units" => array( 2, 3 ) ); NEW PHP CODE: array_map( array("Description", "Price", "Units"), $_POST["Invoice"]["Description"], $_POST["Invoice"]["Price"], $_POST["Invoice"]["Units"] ); NEW PHP RESULT: array( 0 => array( "Description" => "A widget", "Price" => "$1.00", "Units" => 2 ), 1 => array( "Description" => "A gadget", "Price" => "$3.00", "Units" => 3 ) ) I don't think this feature would be difficult to implement and it would be a great addition to array_map's functionality.