Как сравнить 2 строки в алфавитном порядке в PHP?

"Пред Windows 2000" имя т.е. DOMAIN\SomeBody, Somebody часть известна как sAMAccountName.

Так попытка:

using(DirectoryEntry de = new DirectoryEntry("LDAP://MyDomainController"))
{
   using(DirectorySearcher adSearch = new DirectorySearcher(de))
   {
     adSearch.Filter = "(sAMAccountName=someuser)";
     SearchResult adSearchResult = adSearch.FindOne();
   }
}

someuser@somedomain.com.au является UserPrincipalName, но это не обязательное поле.

55
задан aviraldg 23 March 2018 в 05:10
поделиться

4 ответа

Use strcmp. If the first argument to strcmp is lexicographically smaller to the second, then the value returned will be negative. If both are equal, then it will return 0. And if the first is lexicograpically greater than the second then a positive number will be returned.

nb. You probably want to use strcasecmp(string1,string2), which ignores case...

88
ответ дан 7 November 2019 в 07:17
поделиться

You can compare both strings with strcmp:

Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

11
ответ дан 7 November 2019 в 07:17
поделиться

sort

EDIT только что реализованные значения из разных массивов, может сначала array_merge , но не уверен, что это то, что вы хотите

1
ответ дан 7 November 2019 в 07:17
поделиться

I often use natsort (Natural Sort), since I usually just want to preserve the array for later use anyway.

Example:

natsort($unsorted_array);

var_dump($usorted_array); // will now be sorted.
1
ответ дан 7 November 2019 в 07:17
поделиться
Другие вопросы по тегам:

Похожие вопросы: