Loops through the root directories and returns the first match.
string $path An absolute path:
array $roots An array of root directories:
string|null The matching root directory, if found
private static function findRootDir($path, array $roots) {
foreach ($roots as $root) {
if (0 === strpos($path, $root)) {
return $root;
}
}
}