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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:26:34+00:00 2026-05-16T17:26:34+00:00

I’m comparing a string from the database to a list of strings in an

  • 0

I’m comparing a string from the database to a list of strings in an array:

if (in_array($entry, array('Söme string', 'other-string')))

This works for other-string, but not for Söme string, the main difference beeing that this string has an umlaut and an html entity in it. If $entry is Söme string in the database, the comparison fails, even though it should be the same string.

I also tried strcmp and direct comparison using === and ==, but the comparison is always negative. I also tried utf8_encode before comparison, but that did nothing.

The database is using UTF-8, I fetch the data using Drupal API functions and my php file is also UTF-8 encoded. If I print $entry and Söme string to the output HTML, they are indistinguishable.

Any idea what could be causing this behaviour?

Update

Thanks for the help. It seems the   is converted on the way and is stored as a real non-breaking space in the database, not as an HTML entity. Printing it converts it back to an HTML entity (or maybe Firebug does that when I look at it).

The output of var_dump() (using print function, taken from resulting html source):

$entry: string(14) "Söme string"

"Söme string": string(18) "Söme string"

(I’ve edited the string as the real one contains a name)

Update 2

I’ve changed the string to "Some string" and here’s the output of

var_dump(bin2hex($entry));
var_dump(bin2hex('Some string'));

$entry: string(24) "536f6d65c2a0737472696e67"
"Some string": string(32) "536f6d65266e6273703b737472696e67"
  • 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-16T17:26:35+00:00Added an answer on May 16, 2026 at 5:26 pm

    Then the strings are not the same. Perhaps:

    • $entry has an actual space instead of a non-breaking space.
    • One has the HTML entity   while the other has an actual non-breaking space.
    • In one of the scripts the character ö is decomposed and in the other it isn’t.

    Try to var_dump the array and $entry.

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

Sidebar

Related Questions

No related questions found

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.