PHP asort() ফাংশন

উদাহরণ

অ্যাসোসিয়েটেড অ্যারেকে কী-মান অনুযায়ী আদ্যসূত্রে সারিবে:

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

চালু করুন

পরিভাষা ও ব্যবহার

asort() ফাংশন অ্যাসোসিয়েটেড অ্যারেকে কী-মান অনুযায়ী আদ্যসূত্রে সারিবে。

Tip:Please use arsort() The function sorts an associative array in descending order by key value.

Tip:Please use ksort() The function sorts an associative array in ascending order by key name.

Syntax

asort(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. Sort each item in regular order (Standard ASCII, do 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 by setlocale())
  • 4 = SORT_NATURAL - Treats each item as a string, using a natural sorting similar to natsort()
  • 5 = SORT_FLAG_CASE - Can combine (bitwise OR) SORT_STRING or SORT_NATURAL to sort strings without case sensitivity

Description

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

The optional second parameter contains additional sorting identifiers.

Returns TRUE if successful, otherwise returns FALSE.

Technical Details

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