我正在使用wordpress网站,我需要通过自定义列名“IDlisting”对某些用户的数组进行排序
如何通过'IDlisting'对此数组进行排序?
Array
(
[0] => stdClass Object
(
[ID] => 6
[user_login] => adri
[user_url] =>
[user_status] => 0
[display_name] => adrian
[IDlisting] => 6
)
[1] => stdClass Object
(
[ID] => 1
[user_login] => admin
[user_nicename] => admin
[user_activation_key] =>
[user_status] => 0
[display_name] => admin
[IDlisting] => 0
)
)
我试过
$args = array('orderby' => 'IDlisting',
'order' => 'ASC'
);
$authors = get_users($args);
但它不起作用
答案 0 :(得分:0)
http://codex.wordpress.org/Function_Reference/get_users
orderby - 按'nicename','email','url','registered','display_name'或'post_count'排序。
本地支持IDlisting排序
答案 1 :(得分:0)
如果您在数组中得到结果,那么您可以手动对数组进行排序。
<?php
header("Content-type: text/plain");
$data = array();
$data[] = array("id" => 6, "user_login" => "adri", "url" => "", "user_status" => 0, "display_name" => "adrian", "IDlisting" => 6);
$data[] = array("id" => 1, "user_login" => "admin", "url" => "", "user_status" => 0, "display_name" => "admin", "IDlisting" => 1);
var_dump($data);
echo "-----------------------------\n";
function cmp($a, $b)
{
return $a["IDlisting"] - $b["IDlisting"];
}
uksort($data, "cmp");
var_dump($data);
?>