note 111713 deleted from function.ksort by aharvey

From: Date: Wed, 20 Mar 2013 18:50:47 +0000
Subject: note 111713 deleted from function.ksort by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-194143@lists.php.net to get a copy of this message
Note Submitter: sorry_nomail at nospam dot com ---- Thank's to Haprog Here is a function from Haprog to recursively sort multidimentional arrays by key, with limit deep : function deep_ksort(&$arr,$deep=9999) { if (is_array($arr) { ksort($arr); $deep--; if($deep) { foreach ($arr as &$a) { if (is_array($a) && !empty($a)) { deep_ksort($a,$deep); } } } } } deep_ksort($array,1) is like ksort($array); The same with krsort : function deep_krsort(&$arr,$deep=9999) { if (is_array($arr) { krsort($arr); $deep--; if($deep) { foreach ($arr as &$a) { if (is_array($a) && !empty($a)) { deep_krsort($a,$deep); } } } } }

« previous php.notes (#194143) next »