Skip to content
Advertisement

Find a a value in a multidimentional array, and return a value from the same array

I’m trying to find a value in a milti array’s array, and after finding it, I want to return a different key, not sure how to explain it further.

I have an array:

JavaScript

I’m trying to find the array by [custom_tab_field_id], and return the current’s array [status].

I created a function that should do just that, but it’s always returning 0.

The function:

JavaScript

and then simply call for the function by passing values

JavaScript

Advertisement

Answer

With the array_column function, this can be easily solved and is very universal.

JavaScript

The solution contains no error handling and only shows the principle. $arrKeyValue is a array how:

JavaScript

try self on https://3v4l.org/SnVM4

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