11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5 • ARRAYSwww.it-ebooks.infoArray ( [0] => Delaware [2] => New Jersey [1] => Pennsylvania )If you use the optional sort_flags parameter, the exact sorting behavior is determined by its value,as described in the sort() section.Sorting an Array in Reverse OrderThe rsort() function is identical to sort(), except that it sorts array items in reverse (descending) order.Its prototype follows:void rsort(array array [, int sort_flags])An example follows:$states = array("Ohio", "Florida", "Massachusetts", "Montana");rsort($states);print_r($states);It returns the following:Array ( [0] => Ohio [1] => Montana [2] => Massachusetts [3] => Florida )If the optional sort_flags parameter is included, the exact sorting behavior is determined by itsvalue, as explained in the sort() section.Sorting an Array in Reverse Order While Maintaining Key/Value PairsLike asort(), arsort() maintains key/value correlation. However, it sorts the array in reverse order. Itsprototype follows:void arsort(array array [, int sort_flags])An example follows:$states = array("Delaware", "Pennsylvania", "New Jersey");arsort($states);print_r($states);It returns the following:Array ( [1] => Pennsylvania [2] => New Jersey [0] => Delaware )If the optional sort_flags parameter is included, the exact sorting behavior is determined by itsvalue, as described in the sort() section.122

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!