note 7950 added to arsort

From: Date: Mon, 21 Aug 2000 22:43:33 +0000
Subject: note 7950 added to arsort
Groups: php.notes 
Request: Send a blank email to php-notes+get-2909@lists.php.net to get a copy of this message
I was having trouble with the arsort() function on an older version of PHP which was returning an error along the lines of 'wrong perameter count for function arsort' when I tried to use a flag for numeric sorting (2/SORT_NUMERIC).<br> I figured, as I only wanted to sort integers, I could pad numbers from the left to a specific length with 0's (using the lpad function provided by improv@magma.ca in the notes at http://www.php.net/manual/ref.strings.php).<br> A string sort then correctly sorts numerically (i.e. {30,2,10,21} becomes {030,021,010,002} not {30,21,2,10}) when echoing the number an (int)$string_name hides the leading 0's.<br> Made my day :).<br> <br> Rodders. http://www.php.net/manual/function.arsort.php

« previous php.notes (#2909) next »