note 7950 modified in arsort by ronabop

From: Date: Sun, 03 Sep 2000 09:53:28 +0000
Subject: note 7950 modified in arsort by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-4020@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). 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). 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. Made my day :). Rodders. http://www.php.net/manual/function.arsort.php

« previous php.notes (#4020) next »