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

  • Home
  • SEARCH
  • 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 731249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:00:18+00:00 2026-05-14T07:00:18+00:00

When I compare two array values I see two strings that look the same.

  • 0

When I compare two array values I see two strings that look the same. php doesn’t agree.

$array1 = array('address'=>'32 Winthrop Street','state'=>'NY');
$array2 = array('address'=>'32 Winthrop Street');

$results = array_diff_assoc($array1, $array2);

var_dump($results) 
//echos ['address'] => string(18) "32 Winthrop Street" ['state']=>'NY'

Why is this?

EDIT
Be advised that this isn’t the actual code I’m testing, I’ve simplified code to illustrate my question, which is about strings being equal, not whether or not this code will run.

  • 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-14T07:00:18+00:00Added an answer on May 14, 2026 at 7:00 am

    Make sure your input arrays really look like that. If you’re echoing data in your browser, you might miss whitespace. '32 Winthrop Street' is not the same as ' 32 Winthrop Street', for example. The same is true for your array keys.

    You could $array1 = array_map('trim', $array1) and $array2 = array_map('trim', $array2) to remove leading and trailing whitespace from the values. See if that makes any difference?

    You can check if they’re really the same by checking if ($array1['address'] === $array2['address']). If that evaluates to false, there’s a difference, you’re just not seeing it (see binaryLV’s answer for elaboration on a possible cause). If it evaluates to true, you might want to take a closer look at the array keys.

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look for "Bundle display name" inside your application info.plist. May 16, 2026 at 4:04 pm
  • Editorial Team
    Editorial Team added an answer Consider this code: %# here you have your data X/Y/..… May 16, 2026 at 4:04 pm
  • Editorial Team
    Editorial Team added an answer (Undeleting this as per discussion above...) I'm not sure whether… May 16, 2026 at 4:04 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to use simpletest to compare two numeric strings, one from an array
I need to compare two dates using the Oracle decode function to see if
I have been trying to compare two arrays. Using array_intersect presents no problems. When
i try to compare two class comp1,comp2 i used method below: ComparerCollection(array_X, array_Y); but
I've written a Powershell script which will compare two databases and come up with
Is there a way to compare two arrays and show what is common to
i try to compare two lists with each other: ListA (a1,a2,a3,...) ListB (b1,b2,b3,...) I
In a sane world, this works as expected: var array:Array = ['a','b','c']; trace(array.indexOf(array[0])); //
I'm working in a LAMP environment, so PHP is the language; at least i
Assuming we have: array1 = ['A', 'B', 'C', 'D', 'E']; array2 = ['C', 'E'];

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.