I have two arrays, I want to return an array which contains only the keys that are in my template:
$protected template = ['name' => 'john', 'age'=> 10];
public function merge($params){
$arr = array_intersect_key($params, $this->template);
}
The above works, but I would also like to filter out keys where the value is empty.
So if I pass in:
[name => 'jeff', age => '']
It would just filter out an array of:
[name => 'jeff']
Is there a way to do this or would it be best to just loop through the array and do an empty check?