You can do this
```php
$key = array_search('controllers', $folder_tree);
if (strpos($filename,'override')) {
  $key += 3;
}
```