Doc #62299 [Opn->Csd]: array_two_key_swap wrong

From: Date: Fri, 22 Jun 2012 21:57:49 +0000
Subject: Doc #62299 [Opn->Csd]: array_two_key_swap wrong
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8500@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62299&edit=1 ID: 62299 Updated by: salathe@php.net Reported by: bubrak at pinknet dot cz Summary: array_two_key_swap wrong -Status: Open +Status: Closed Type: Documentation Problem Package: Arrays related Operating System: FreeBSD PHP Version: 5.3.13 -Assigned To: +Assigned To: salathe Block user comment: N Private report: N New Comment: Your note was most likely deleted because on the note submission page [1] we explicitly ask note submitters not to add: - References to other notes or authors - Code collaboration or improvements The referenced note has also been deleted. [2] [1] http://www.php.net/manual/add-note.php [2] http://news.php.net/php.notes/188764 Previous Comments: ------------------------------------------------------------------------ [2012-06-12 09:58:47] bubrak at pinknet dot cz Description: ------------ --- From manual page: http://www.php.net/function.array --- User note bellow array() manual dated "10-Oct-2009 01:39" showing function array_two_key_swap is misleading and will cost other users time, as it is not working in the way it says - tranferring array[k1][k2] into array[k2][k1], it only works for integer k2 keys which is wrong. I entered simplier function as a new note but it was deleted. I don't understand why misleading code is kept online with PHP manual and proper fix is deleted. Test script: --------------- It is obvious. No need to show it here. Proper code is here: <?php function array_two_key_swap( $a ) { $ra = array(); while (list($k1,$v1) = each ($a)) { while (list($k2,$v2) = each ($v1)) { $ra[$k2][$k1]=$v2; } } return $ra; } ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62299&edit=1

« previous php.doc.bugs (#8500) next »