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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:21:36+00:00 2026-06-13T15:21:36+00:00

Possible Duplicate: PHP : Array key containing special character not found I am comparing

  • 0

Possible Duplicate:
PHP : Array key containing special character not found

I am comparing strings to determine corresponding numbers for the strings. The one set of strings is stored in a MySQL DB and the other set of strings are stored as keys for an array in php.

When trying to lookup the following string, it is not found in the array.
“Child attending pre-school/nursery school/crèche/day-mother”

More information on the code is available in this previous question that led me to the following test.

After doing a hex dump as suggested, I got the following results

From MySQL DB:

43 68 69 6c 64 20 61 74 74 65 6e 64 69 6e 67 20 70 72 65 2d 73 63 68 6f 6f 6c 2f 6e 75 72 73 65 72 79 20 73 63 68 6f 6f 6c 2f 63 72 e8 63 68 65 2f 64 61 79 2d 6d 6f 74 68 65 72

From string in php:

43 68 69 6c 64 20 61 74 74 65 6e 64 69 6e 67 20 70 72 65 2d 73 63 68 6f 6f 6c 2f 6e 75 72 73 65 72 79 20 73 63 68 6f 6f 6c 2f 63 72 c3 a8 63 68 65 2f 64 61 79 2d 6d 6f 74 68 65 72

The difference was “E8” vs “C3A8” or “è” from the MySQL DB vs “è” from the php string.

So how can I go about ensuring the hard coded php array key character remains “è”?

  • 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-13T15:21:38+00:00Added an answer on June 13, 2026 at 3:21 pm

    You should use the same enconding in both PHP and MySQL.

    If your PHP string is UTF-8 encoded, your tables’ charset must be utf8 and the collation should be utf8_general_ci or utf8_unicode_ci. Also, you have to tell MySQL that you want the results you query in UTF-8 too. Here are three ways to achieve this:

    1. Query on connect: Execute SET NAMES utf8 just after connect to MySQL.
    2. Using PDO: $pdo = new PDO($dsn, $user, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); This is basically the same as above but auto-performed by PDO.
    3. Permanent (my.cnf): This will set UTF-8 implicit for all connections. Just add: init-connect='SET NAMES utf8' to MySQL’s config file my.cnf.

    I personaly use the 3rd option but in a shared environment I’d choose the 2nd one.

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

Sidebar

Related Questions

Possible Duplicate: PHP: Filter array I have a PHP array containing strings of random
Possible Duplicate: PHP get both array value and array key I am using Codeigniters'
Possible Duplicate: In PHP, how do you change the key of an array element?
Possible Duplicate: Changing a nested (multidimentional) array into key => value pairs in PHP
Possible Duplicate: Is it okay to use array[key] in PHP? Is there any significant
Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some
Possible Duplicate: php values of one array to key of another array i have
Possible Duplicate: Search for PHP array element containing string I've created a mysql query
Possible Duplicate: php values of one array to key of another array I have
Possible Duplicate: PHP String in Array Only Returns First Character I've got following problem.

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.