Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:51:33+00:00 2026-06-05T12:51:33+00:00

Is there any example of using SORT_LOCALE_STRING where it would give a different result

  • 0

Is there any example of using SORT_LOCALE_STRING where it would give a different result to the default SORT_STRING when using array_unique?

Here is some code that shows how you can get different results between SORT_STRING, SORT_REGULAR, SORT_NUMERIC.

<?php
$list = array(
  '0',
  null,
  0,
  10,
  '10.0',
  '1e1',
  false,
  ''
);
var_dump(array_unique($list));
var_dump(array_unique($list, SORT_NUMERIC));
var_dump(array_unique($list, SORT_REGULAR));

Output:

array(5) {
  [0]=>
  string(1) "0"
  [1]=>
  NULL
  [3]=>
  int(10)
  [4]=>
  string(4) "10.0"
  [5]=>
  string(3) "1e1"
}
array(2) {
  [0]=>
  string(1) "0"
  [3]=>
  int(10)
}
array(4) {
  [0]=>
  string(1) "0"
  [1]=>
  NULL
  [3]=>
  int(10)
  [7]=>
  string(0) ""
}

Please help me find an example that shows a use for SORT_LOCALE_STRING.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:51:34+00:00Added an answer on June 5, 2026 at 12:51 pm

    I guess in german, ß and ss are considered lexicographically equal I think. Basically, they should be considered the same character and sort as such. If you don’t use a locale sensitive string comparison(sorting is string comparison), then, I think it’s pretty obvious those two strings wont compare as being equal.

    $array = array('ß', 't', 'ss');
    //binary safe transport of the above chars as present in my text editor
    $array = unserialize(base64_decode('YTozOntpOjA7czoxOiLfIjtpOjE7czoxOiJ0IjtpOjI7czoyOiJzcyI7fQ=='));
    setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
    echo setlocale(LC_ALL, '0'), "\n";
    var_dump(strcoll('ß', 'ss'));
    var_dump(array_unique($array, SORT_LOCALE_STRING));
    

    yields, on my machine(win7, php5.4rc2)

    German_Germany.1252
    int(0)
    array(2) {
      [0]=>
      string(1) "ß"
      [1]=>
      string(1) "t"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any example on using java method to call rhino-javascript function and return
Is there any example for a Real Time Chart using the DexExpress in ASP.Net?
Is there any way to write Shoes application using IDE (NetBeans for example)? I
Is there any advantage of using {} instead of string concatenation? An example from
Using GScript for example, is there any harm that can come to a phone
Is there any example for Composite Pattern with Doctrine? I mean PHP source code
Is there any code example teaching how to zoom in and out in a
Is there any open source (or example) code for Ruby on Rails which can
I am using the Cancan accessible_by to retrieve a ActiveRecord::Relation result (example code below).
Are there any examples of Store Locators using Google API v3 without using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.