- var_dump: documentation ( source)
- array_flip: documentation ( source)
<?php
$arr1 = [
'main' => [
'number1' => '9000.99',
'number2' => 'nonono'
]
];
$arr2 = [
'key1' => ['number1','b','c']
];
function read($arr, $arr2) {
foreach ($arr as $key => $value) {
if (is_array($value)) {
read($value, $arr2);
}
else {
echo $key;
foreach($arr2 as $action) {
var_dump($action);
if(array_key_exists($key, array_flip($action))){
echo $value;
}
}
}
}
}
read($arr1, $arr2);