Which is a more efficient way of comparing an array's keys with a template and filtering out empty values? Then operating on the remaining parts of the array?
$arr = array_intersect_key(array_filter($arr), $this->arrTemplate);
foreach ($arr as $_k => $_v) {
//Do something
Or this:
foreach ($arr as $_k => $_v) {
if (array_key_exists($_k, $this->arrTemplate)) {
if (empty($_v)) {
continue;
}
//Do something
}
}
Also as a side question, how can I measure efficiency for myself?