本文整理汇总了PHP中api_strcmp函数的典型用法代码示例。如果您正苦于以下问题:PHP api_strcmp函数的具体用法?PHP api_strcmp怎么用?PHP api_strcmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_strcmp函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sort_users
/**
* Function to sort users after getting the list in the DB.
* Necessary because there are 2 or 3 queries. Called by usort()
*/
function sort_users($user_a, $user_b)
{
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
}
}
示例2: sort_users
/**
* Function to sort users after getting the list in the DB.
* Necessary because there are 2 or 3 queries. Called by usort()
*/
function sort_users($user_a, $user_b)
{
$orderListByOfficialCode = api_get_setting('platform.order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$cmp = api_strcmp($user_a['official_code'], $user_b['official_code']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
}
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
}
}
示例3: sort_users
/**
* Function to sort users after getting the list in the DB.
* Necessary because there are 2 or 3 queries. Called by usort()
*/
function sort_users($user_a, $user_b)
{
global $_configuration;
if (isset($_configuration['order_user_list_by_official_code']) && $_configuration['order_user_list_by_official_code']) {
$cmp = api_strcmp($user_a['official_code'], $user_b['official_code']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
}
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
}
}
}
}
示例4: sort_by_first_name
public function sort_by_first_name($item1, $item2)
{
return api_strcmp($item1[3], $item2[3]);
}
示例5: sort_by_user
function sort_by_user($item1, $item2)
{
$user1 = $item1['user'];
$user2 = $item2['user'];
if (api_sort_by_first_name()) {
$result = api_strcmp($user1['firstname'], $user2['firstname']);
if ($result == 0) {
return api_strcmp($user1['lastname'], $user2['lastname']);
}
} else {
$result = api_strcmp($user1['lastname'], $user2['lastname']);
if ($result == 0) {
return api_strcmp($user1['firstname'], $user2['firstname']);
}
}
return $result;
}
示例6: api_strcasecmp
/**
* Performs string comparison, case insensitive, language sensitive, with extended multibyte support.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return int Returns < 0 if $string1 is less than $string2; > 0 if $string1 is greater than $string2; and 0 if the strings are equal.
* This function is aimed at replacing the function strcasecmp() for human-language strings.
* @link http://php.net/manual/en/function.strcasecmp
*/
function api_strcasecmp($string1, $string2, $language = null, $encoding = null)
{
return api_strcmp(api_strtolower($string1, $encoding), api_strtolower($string2, $encoding), $language, $encoding);
}
示例7: rsort_users
function rsort_users($a, $b)
{
return api_strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
}
示例8: sort_by_description
function sort_by_description($item1, $item2)
{
$result = api_strcmp($item1->get_description(), $item2->get_description());
if ($result == 0) {
return $this->sort_by_name($item1, $item2);
}
return $result;
}
示例9: sort_by_first_name
function sort_by_first_name($item1, $item2)
{
return api_strcmp($item1['firstname'], $item2['firstname']);
}