Reply to Re: Best way to sort arrays

Your name:

Reply:


Posted by Michael Fesser on 11/01/07 18:10

..oO(floortje)

>I agree .... there are ways to work around the problem.
>
>I could do something like:
>
>echo 'Last 5 entries';
>for ($i=count($allentries),$i>(count($allentries)-5);$i--)
>{
>echo $allentries[--$i].'<br />';
>}
>
>But It still bothers me that I cant simply extract 5 rows that have
>largest/smallest value in an array field from a multi dimentional
>array. Is there really no better way to do this ?

For extracting a part of an array there is array_slice(), which should
work for your latest entries. For getting the modified ones you could
sort the array with a user-defined comparison function and then use
array_slice() again. You could also try array_filter(). The callback
function just has to check if the entry was modified.

Micha

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация