note 72982 rejected from function.array-flip by colder
| From: | colder@php.net | Date: | Tue, 06 Feb 2007 20:27:31 +0000 |
| Subject: | note 72982 rejected from function.array-flip by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122940@lists.php.net to get a copy of this message | ||
Note Submitter: rlee0001 at sbcglobal dot net
----
I'd like to see "rgonzalez at kidchile dot cl"s function to transpose an array built
in to PHP. This seems like a core array function for processing complex incoming POST data. Consider
this HTML form:
<input name="a[]" value="1">
<input name="b[]" value="1">
<input name="c[]" value="1">
<input name="a[]" value="2">
<input name="b[]" value="2">
<input name="c[]" value="2">
<input name="a[]" value="3">
<input name="b[]" value="3">
<input name="c[]" value="3">
...this gives us (in $_POST):
<?php
array(
'a' => array('1', '2', '3', ),
'b' => array('1', '2', '3', ),
'c' => array('1', '2', '3', ),
)
?>
I would like to be able to go from that, to:
<?php
array(
array('a' => '1', 'b' => '1', 'c' =>
'1', ),
array('a' => '2', 'b' => '2', 'c' =>
'2', ),
array('a' => '3', 'b' => '3', 'c' =>
'3', ),
)
?>
...without writing a custom function to do so (all we are doing is rotating the array). Maybe in
PHP7?