I have an array with some values as below:
$array1 = [
0 => "year",
1 => "month"
];
I make a loop to this array and check if its value exist in following array.
array:3 [
0 => array:3 [
"name" => "year"
"mandatory" => true
"type" => "integer"
]
1 => array:3 [
"name" => "month"
"mandatory" => true
"type" => "integer"
]
2 => array:3 [
"name" => "id"
"mandatory" => false
"type" => "integer"
]
]
If if exists then I have to return array something like this
array[
"year" => [
"mandatory" => true
"type" => "integer"
],
"month" => [
"mandatory" => true
"type" => "integer"
],
]
This is the code so far I have tried.
$keys = array_keys($params);
$fields = $config["fields"];
$finalArr = array();
foreach($keys as $key) {
if(in_array($key, array_column($fields, "name"))) {
$finalArr[$key] = array();
}
$finalArr[$key][] = $fields;
}
But this returns all the records.
Can anybody help me.