Re: retrieve top n entries from an associative array
- From: Myron Turner <mturner@xxxxxxxxxxxxxxx>
- Date: Sat, 30 Dec 2006 22:15:12 GMT
array array_slice ( array array, int offset [, int length])
<?php
$top_ten = array_slice ( $sorted, 0 , 10);
$a= array (1,2,3,4,5,6,7,8,9,10,11,12);
$top_ten = array_slice ( $a, 0, 10);
print_r ($top_ten);
?>
/* Result:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
)
*/
duzhidian@xxxxxxxxx wrote:
Hello,
After sorting an associative array by value, how can I retrieve top n
entries from it?
Thanks.
Zhidian Du
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
.
- Follow-Ups:
- Re: retrieve top n entries from an associative array
- From: duzhidian@xxxxxxxxx
- Re: retrieve top n entries from an associative array
- References:
- retrieve top n entries from an associative array
- From: duzhidian@xxxxxxxxx
- retrieve top n entries from an associative array
- Prev by Date: Re: [PHP] php/ajax question
- Next by Date: Re: [PHP] php/ajax question
- Previous by thread: Re: retrieve top n entries from an associative array
- Next by thread: Re: retrieve top n entries from an associative array
- Index(es):
Relevant Pages
|