Since you're clarified that your data is derived from some log-file (i.e. not from FS directly, so it may be even non-real directory), you may use this simple method to get your array:
$data = 'abc\xyz
abc\def\ghi
abc\xyz\pqr';
//
$data = preg_split('/[\r\n]+/', $data);
$result = [];
$pointer = &$result;
foreach($data as $path)
{
$path = explode('\\', $path);
foreach($path as $key)
{
if(!isset($pointer[$key]))
{
$pointer[$key] = null;
$pointer = &$pointer[$key];
}
}
$pointer = &$result;
}
-this will result in:
array(3) {
["abc"]=>
array(1) {
["xyz"]=>
NULL
}
["def"]=>
array(1) {
["ghi"]=>
NULL
}
["xyz"]=>
array(1) {
["pqr"]=>
NULL
}
}