Comunitatea PHP Romania
 

 
sort

sort

(PHP 3, PHP 4 , PHP 5)

sort -- Sort an array

Description

void sort ( array array [, int sort_flags])

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

Exemplu 1. sort() example

<?php

$fruits
= array ("lemon", "orange", "banana", "apple");
sort ($fruits);
reset ($fruits);
while (list (
$key, $val) = each ($fruits)) {
    echo
"fruits[".$key."] = ".$val."\n";
}

?>

This example would display:

fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange

The fruits have been sorted in alphabetical order.

The optional second parameter sort_flags may be used to modify the sorting behavior using these values:

Sorting type flags:

  • SORT_REGULAR - compare items normally

  • SORT_NUMERIC - compare items numerically

  • SORT_STRING - compare items as strings

See also arsort(), asort(), ksort(), natsort(), natcasesort(), rsort(), usort(), array_multisort(), and uksort().

Notã: The second parameter was added in PHP 4.

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
acasa , in pat
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
Mascka Mascka
Braila
raul_ raul_
whooper whooper
Toronto ON
mihaitha mihaitha
Sibiu
gabysolomon gabysolomon
Bacau
oriceon oriceon
Constanta
garlicinicolae garlicinicolae

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Broadband Specials | Bad Credit Loan | Mortgage Calculator | Worms For Fishing Bait UK | Debt Consolidation Loan
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis