_wp_object_count_sort_cb()
云策文档标注
概述
_wp_object_count_sort_cb() 是 WordPress 中的一个回调函数,用于基于对象计数进行比较,通常与 uasort() 函数配合使用。
关键要点
- 函数用途:作为回调函数,比较两个对象的 count 属性值。
- 参数说明:接受两个对象参数 $a 和 $b,均为必需。
- 返回值:返回整数,若 $a->count 小于 $b->count 为负数,相等为零,大于则为正数。
- 版本历史:自 WordPress 3.1.0 版本引入。
代码示例
function _wp_object_count_sort_cb( $a, $b ) {
return ( $a->count - $b->count );
}
原文内容
Serves as a callback for comparing objects based on count.
Description
Used with uasort().
Parameters
$aobjectrequired-
The first object to compare.
$bobjectrequired-
The second object to compare.
Source
function _wp_object_count_sort_cb( $a, $b ) {
return ( $a->count - $b->count );
}
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |