[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] PHP: ændre rækkefølgen på et associativt array



On Tue, 24 Oct 2006 09:34:43 +0200, Peter Makholm wrote:

> I PHP har associative arrays en rækkefølge man blandt andet kan aflæse
> ved hjælp af next() og prev() og iterere over med each(). Er der en
> måde jeg kan ændre direkte på denne rækkefølge?
> 
Nej, elementerne indekseres med en indbygget hash funktion. Du har altså to
muligheder for tilgang til dine elementer:
1) sekventielt (O(n)): foreach ($array as $element)
2) Direkte (O(1)): $array['nøgle']

> Helt konkret vil jeg kunne pege på en nøgle og sige 'du skal være
> tilsidst'. Og jeg kan ikke se andre måder at ændre rækkefølgen på end
> med sorteringsfunktionerne.
> 
Du har ingen mulighed for at bestemme placering af et element, da
placeringen bestemmes af hash funktionen.

Er du sikkert på, at du ikke blot skal anvende et almindeligt array? Det
du efterspørger, er fundamentalt i modstring med hash arrays - selv ikke i
Perl har du denne mulighed:-)

-- 
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *