I am trying to find the value of a key in a multi dimensional array while matching the parent key too.
For example:
Array 1 - Array of keys I am trying to find the value of.
$array1 = array(
'title',
'metadata' => array('size', 'mime'),
'dates' => array('published' =>
array('firstedition' => '12/22/22',
'secondedition' => '22/22/22',
'thirdedition'),
'description',
'mime'
);
Array 2: The array I'm searching for the keys in array1
$array2 = array(
'title' => 'hello',
'metadata' => array('size' => '22', 'mime' => 'text/html'),
'dates' => array('published' =>
array('firstedition' => '12/22/22',
'secondedition' => '22/22/22',
'thirdedition' => '22/22/14'),
'type' => 'book',
'description' => 'This is a description',
'mime' => 'something/pdf',
'firstedition' => '99/99/99'
);
All the values in Array 1 are the keys I want to find in Array 2. If the value in Array 1 is an array, I want to find the value in Array 2 respective of the values parents.
For example:
Array 1: Metadata -> Size
Search on Array 2 returns: 22
Array 1: Metadata -> Mime
Search on Array 2 returns: text/html
Array 1: Mime
Search on Array 2 returns: something/pdft
Array 1: dates -> published -> firstedition
Array 2 returns:
12/22/22
Array 1: firstedition
Array 2 returns: 99/99/99
Notice the difference of outputs between "dates -> published -> firstedition" and just "firstedition". So I want to search all the values in array 1 as keys to find within array 2 and display them like:
key -> possiblesubkey -> possiblesubkey : value
If possible to return an array with the path of the key and value for example:
array('dates\published\firstedition', '12/22/22');
array('firstedition', '99/99/99');
Also, Array1 is part of a larger array, with different file types, array1 is under the key "books", and within array2 is the key "type", so depending on what type array2 is the the values from the keys I want in array2 may differ. For example in array1 there might also be "songs" of which I'd like a different set of values for such as "bitrate" but I don't want to look for "firstedition" because it doesn't exist.
I've posted this example as I've already managed to identify what type array2 is and find that corresponding key which outputs what I have posted as array1.
Any help would be greatly appreciated can't seem to get my hand around this.