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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:57:28+00:00 2026-05-26T00:57:28+00:00

Can an array key in PHP be a string with embedded zero-bytes? I wanted

  • 0

Can an array key in PHP be a string with embedded zero-bytes?

I wanted to implode a multi-part key with embedded zero-bytes as the delimiter and use it as the key in an associative array, but it doesn’t seem to be working. Not sure whether this is a problem with the array access or with array_keys_exists().

Does anybody have any idea? Am I going about this the wrong way? Should I be creating a multi-part key in another way?

To clarify, I am trying to eliminated duplicates from user-entered data. The data consists of a product ID, a variation ID, and N fields of textual data. Each of the N fields has a label and a value. To be considered a duplicate, everything must match exactly (product ID, variation ID, all the labels and all the values).

I thought that if a create a string key by concatenating the information with null bytes, I could keep an associative array to check for the presence of duplicates.

  • 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-26T00:57:29+00:00Added an answer on May 26, 2026 at 12:57 am

    From the PHP string documentation:

    There are no limitations on the values the string can be composed of;
    in particular, bytes with value 0 (“NUL bytes”) are allowed anywhere
    in the string (however, a few functions, said in this manual not to be
    “binary safe”, may hand off the strings to libraries that ignore data
    after a NUL byte.)

    From the PHP arrays documentation:

    A key may be either an integer or a string.

    No mention is made of any special case for strings that are array keys.

    So, yes.

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

Sidebar

Related Questions

I have a string like this: http://mysite.com/script.php?fruit=apple And I have an associative array like
Possible Duplicate: Set array key as string not int? I know you can do
How can I add key value pairs to an array? This won't work: public
A PHP array can have arrays for its elements. And those arrays can have
How can i array a string, in the format that $_POST does... kind of,
In PHP I can name my array indices so that I may have something
Can jQuery test an array for the presence of an object (either as part
Is there an already existing function in PHP for creating an associative array from
In PHP, strtr can accept an input of array and replace all occurrence of
I have an PHP array that looks something like this: Index Key Value [0]

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.