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 6184385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:31:43+00:00 2026-05-24T01:31:43+00:00

I am stuck in comparing two unicode strings in PHP which both contain the

  • 0

I am stuck in comparing two unicode strings in PHP which both contain the special char ‘ö’. One string comes from $_GET, the other one is a filesystem’s folder name (scandir()). Both strings seem to be equal to me, making a

var_dump($filter);
var_dump($tail . '/' . $k);

on them also shows their equality but with different string lenghts (?!):

string '/blöb' (length=7)
string '/blöb' (length=6)

My snippet comparing them looks as follows:

if($filter == ($tail . '/' . $k)) {
    /* ... */
}

What’s going on here?

Additional information: $tail is an empty string:

string '' (length=0)
  • 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-05-24T01:31:44+00:00Added an answer on May 24, 2026 at 1:31 am

    See here: http://en.wikipedia.org/wiki/Unicode_equivalence and use this: http://www.php.net/manual/en/class.normalizer.php

    You probably have a decomposed character in the longer string, meaning an o and then a umlaut combining character which overlays the previous character.

    The normalizer function will fix things like that.

    As a side note you should always normalize your input if you are using it for equivalence (for example a username – you want to make sure two people don’t choose the same username, even if the binary representation of the string happens to be different).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm stuck on a PHP 4 server, and I would like to start moving
I'm kinda stuck with this one so I hoped someone could help me. I
I have a Android project which I'm building in Ant and I'm stuck on
I asked a question yesterday about comparing ranges for overlap and its been stuck
I have a bunch of files (almost 100) which contain data of the format:
I am completely stuck on this one. I know my code is correct. It
This is a special case where I am stuck dealing with an enterprise webapp.
I am trying to implement one of the first examples from boost::random documentation in
see i have one complex code but i m stuck up some where so
Being stuck with a legacy database schema that no longer reflects your data model

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.