Here is the code I am looking at.
foreach ($header as $idx => $field) {
if (stripos($field, \'foo\') !== false) {
$cols[\'foo\'] = $idx;
Dunno if something like this would be easier to maintain. Depends if you do something else in those if conditions. But you can set the keys in a config file, db, pass as argument to your function, or similar.
$keys = array(
'foo',
'bar',
'brr',
'ffo',
);
foreach ($header as $idx => $field) {
foreach ($keys as $key) {
if (stripos($field, $key) !== false) {
$cols[$key] = $idx;
break;
}
}
}