Skip to content
Advertisement

Relate data between two 2d arrays based on a shared value in a protected property

I have 2 arrays $userArray and $differentArray.

question: I am trying to find the index value from $userArray where $userId matches from $differentArray so that i can pull the first/last names

print_r of $userArray outputs this:

JavaScript

print_r of $differentArray outputs this:

JavaScript

**and here is my attempt, but it only outputs Joe Smith
*** $differentArray is constructed the same way as $userArray

JavaScript

Advertisement

Answer

Man, use foreach.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement