note 72982 added to function.array-flip

From: Date: Tue, 06 Feb 2007 19:37:40 +0000
Subject: note 72982 added to function.array-flip
Groups: php.notes 
Request: Send a blank email to php-notes+get-122935@lists.php.net to get a copy of this message
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? ---- Server IP: 216.194.113.175 Probable Submitter: 63.125.44.226 ---- Manual Page -- http://www.php.net/manual/en/function.array-flip.php Edit -- https://master.php.net/note/edit/72982 Del: integrated -- https://master.php.net/note/delete/72982/integrated Del: useless -- https://master.php.net/note/delete/72982/useless Del: bad code -- https://master.php.net/note/delete/72982/bad+code Del: spam -- https://master.php.net/note/delete/72982/spam Del: non-english -- https://master.php.net/note/delete/72982/non-english Del: in docs -- https://master.php.net/note/delete/72982/in+docs Del: other reasons-- https://master.php.net/note/delete/72982 Reject -- https://master.php.net/note/reject/72982 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122935) next »