ARRAY 1:
array(1) {
["en"]=>
array(1) {
["em"]=> null
}
}
ARRAY 2 VALUES:
array(15) {
["something"]=>
array(4) {
["somekey1"]=>
string(25) "value1"
["somekey2"]=>
string(9) "value2"
["somekey3"]=>
string(5) "value3"
["somekey4"]=>
string(3) "value4"
}
["en"]=>
array(3) {
["em"]=>
string(4) "RESULT"
Look at array on ["en"]["em"] = "RESULT" from both arrays.
I want using $array1 and $array2 to intersecting a keys of array and get a result from $array2:
NOTE: On Array1 can be more nested arrays, ARRAY1 should find this keys on ARRAY2:
NOTE: I don't want to grab a data like $array2["en"]["em"], only using custom functions. (for example: custom array_intersect())
I have 2 arrays. Look at only keys. On Array1 there is en,em keys. I want these two keys to intersecting on Array2. When is intersecting with Array2, it will on Array2 get a value en,em->RESULT. I don't want a classical way to grab a data, just a COMPARE TWO ARRAYS and GET A VALUE.
I've tried intersecting, but this ONLY works if two arrays ARE SAME. So, I need to intersecting using nested recursive searching by key!
Example, I don't want:
$array2['en']['em'];
some_function_to_search_array_by_key(array $array2);
Example, that I WANT to:
Using function `array_intersect()` or some hardcoded sample.
get_result_by_two_arrays($array1, $array2);
Example of Result:
INPUT:
// search by arrays keys
$array1 = array('en' => 'em');
$result = get_result_by_two_arrays($array1, $array2);
RESULT:
$result =
(string)RESULT;
array2usingarray_intersect()but it's strings problem. I want grabbing a data fromarray2using compare keys and pick up a value fromarray2.$array1 = ['en' => ['em' => null]];from top is not different from$array1 = ['en' => 'em'];in example.