**Using PHP 8.0.**

I want to search a line for regex matches and replace all those matches with a string. Here is the code I wrote to find matches:

```php
// $lines is an array of html document lines
function include_files(array $lines): array {
    $pattern = '/{FILE="[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+"}/';
    foreach ($lines as $line){
        preg_match_all($pattern, $line, $matches);
        var_dump($matches);
        foreach ($matches[0] as $match) {
            $file_name = get_block_file($match[0]);
            $file_content = file_get_contents($file_name);
            $line = str_replace($match[0], $file_content, $line);
        }
    }
    return $lines;
}

```

The problem is that `var_dump($matches)` displays the following:

```
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(1) { [0]=> string(6) "{FILE="1.txt"" } } 
array(1) { [0]=> array(0) { } } 
array(1) { [0]=> array(0) { } }

```

One of these arrays contains what I need, but neither can I accesses it nor can I understand where do all these other arrays come from. How can I fix this behavior?