From: Operating system: linux PHP version: Irrelevant Package: Arrays related Bug Type: Feature/Change Request Bug description:please implement recursive ksort
Description: ------------ I've a problem wherein I'm using SimpleTest's testIdentical to compare nested arrays, and if the key order differs it throws an error. What I really care about is making sure the same content exists in both, order independent. My solution was to implement a recursive ksort to run the nested arrays through to guarantee key order was the same, regardless of how the arrays are given to me initially. It seems like it would be useful to have this functionality in base php. Test script: --------------- My short php-based implementation looks like this: function rksort($array = null) { if (!...@is_array($array)) return $array; ksort($array); foreach ($array as $index => $notused) { $array[$index] = rksort($array[$index]); } return $array; } Expected result: ---------------- Results confirm expectations: the data structure is key sorted recursively using ksort. -- Edit bug report at http://bugs.php.net/bug.php?id=52177&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52177&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52177&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52177&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52177&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52177&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52177&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52177&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52177&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52177&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52177&r=support Expected behavior: http://bugs.php.net/fix.php?id=52177&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52177&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52177&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52177&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52177&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52177&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52177&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52177&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52177&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52177&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52177&r=mysqlcfg