PHP arsort() ਫੰਕਸ਼ਨ

ਇੰਸਟੈਂਸ

ਅਸੋਸੀਏਟਿਡ ਅਰਰੇ ਨੂੰ ਕੀ ਮੁੱਲ ਉੱਤੇ ਘੱਟੋ-ਘੱਟ ਕਰੋ:

<?php
$age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31");
arsort($age);
?>

ਚਲਾਉਣ ਵਾਲਾ ਇੰਸਟੈਂਸ

ਵਿਆਖਿਆ ਅਤੇ ਵਰਤੋਂ

arsort() ਫੰਕਸ਼ਨ ਅਸੋਸੀਏਟਿਡ ਅਰਰੇ ਨੂੰ ਕੀ ਮੁੱਲ ਉੱਤੇ ਘੱਟੋ-ਘੱਟ ਕਰਦਾ ਹੈ。

Tip:Please use asort() The function sorts the associated array in ascending order by key value.

Tip:Please use krsort() The function sorts the associated array in descending order by key name.

Syntax

arsort(array,sortingtype);
Parameters Description
array Required. Specifies the array to be sorted.
sortingtype

Optional. Specifies how to sort the elements/items of the array. Possible values:

  • 0 = SORT_REGULAR - Default. Sorts each item in regular order (Standard ASCII, does not change type).
  • 1 = SORT_NUMERIC - Treats each item as a number.
  • 2 = SORT_STRING - Treats each item as a string.
  • 3 = SORT_LOCALE_STRING - Treats each item as a string, based on the current locale setting (can be changed via setlocale()).
  • 4 = SORT_NATURAL - Treats each item as a string, using a natural sorting similar to natsort().
  • 5 = SORT_FLAG_CASE - Can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings without case sensitivity.

Description

The arsort() function sorts an array in reverse order while maintaining the index relationship. It is mainly used to sort combined arrays where the order of the units is very important.

The optional second parameter includes additional sorting identifiers.

Returns TRUE if successful, otherwise FALSE.

Technical Details

Return Value: Returns TRUE if successful, FALSE otherwise.
PHP Version: 4+