- Trang chủ
- Phát triển web
- PHP
- Hàm uasort[] trong PHP
Hướng dẫn cách sử dụng hàm uasort[] về mảng trong lập trình PHP
Nội dung chính
- Tác dụng của hàm uasort[]
- Bài viết này đã giúp ích cho bạn?
- Bài viết mới
- Cú pháp của hàm uasort [] trong PHP là gì?
- Ví dụ về hàm uasrt []
- Định nghĩa hàm uasort[] trong PHP
- Cú pháp hàm uasort[] trong PHP
- Ví dụ minh họa cách sử dụng hàm uasort[] trong PHP:
Tác dụng của hàm uasort[]
Bài viết này đã giúp ích cho bạn?
Bài viết mới
Cú pháp của hàm uasort [] trong PHP là gì?
Ví dụ về hàm uasrt [] |
Định nghĩa hàm uasort[] trong PHP |
Cú pháp hàm uasort[] trong PHP
Ví dụ minh họa cách sử dụng hàm uasort[] trong PHP:
The uasort[]
function sorts an array by values using a user-defined comparison function.[array, compare_function];
The keys are preserved, i.e. the key-to-value mapping will remain unchanged by the sort operation.
The following table summarizes the technical details of this function.
Returns TRUE
on success or FALSE
on failure. The comparison function must return an integer equal to
zero if both values are equal, an integer less than zero if the first value is less than the second value, and an integer greater than zero if the first value is greater than the second value.
PHP 4+
Syntax
The following example shows the uasort[] function in action. | The uasort[] function is mainly used for sorting associative arrays by value. To sort an associative array by keys using a user-defined comparison function use the 0 function. |
Note: The comparison function must return an integer equal to zero if both values are equal, an integer less than zero if the first value is less than the second value, and an integer greater than zero if the first value is greater than the second value. | Parameters |
Bài viết này đã giúp ích cho bạn?
Bài viết mới
Cú pháp của hàm uasort [] trong PHP là gì?
Cú pháp của hàm uasort [] trong PHP là gì?
Ví dụ về hàm uasrt []Ví dụ minh họa cách sử dụng hàm uasort[] trong PHP: | The uasort[] function sorts an array by values using a user-defined comparison function. |
The keys are preserved, i.e. the key-to-value mapping will remain unchanged by the sort operation. | The following table summarizes the technical details of this function. Hàm có thể gọi so sánh hai giá trị và trả về một số nguyên 0 nếu giá trị đầu tiên hơn giá trị thứ hai. |
TRUE
on success or FALSE
on failure. Ví dụ về hàm uasrt []
Định nghĩa hàm uasort[] trong PHP Sắp xếp các phần tử mảng theo giá trị bằng cách sử dụng hàm do người dùng xác định để so sánh các giá trị.
Định nghĩa hàm uasort[] trong PHP
Cú pháp hàm uasort[] trong PHP
Cú pháp hàm uasort[] trong PHP
Ví dụ minh họa cách sử dụng hàm uasort[] trong PHP: có cú pháp như sau:
uasort[array, myfunction]
2Định nghĩa hàm uasort[] trong PHP
The following example shows the uasort[] function in action. | The uasort[] function is mainly used for sorting associative arrays by value. To sort an associative array by keys using a user-defined comparison function use the 0 function. |
Note: The comparison function must return an integer equal to zero if both values are equal, an integer less than zero if the first value is less than the second value, and an integer greater than zero if the first value is greater than the second value. | Parameters The
|
Required. Specifies the array to be sorted.
compare_function
Ví dụ minh họa cách sử dụng hàm uasort[] trong PHP:
The uasort[]
function sorts an array by values using a user-defined comparison function.
The keys are preserved, i.e. the key-to-value mapping will remain unchanged by the sort operation.