PHP数组中的Git Diff OutPut

Having an issue getting a gitt diff output to be stored as an array in PHP.

$modifiedFiles = `git diff --cached --name-only --diff-filter=ACMR HEAD -- '*.php'`;

var_dump($modifiedFiles);

OUTPUT:

 """
    app/Http/Controllers/HomeController.php

    app/Http/Controllers/LawyerController.php

    """

I then tried:

$modifiedFiles = explode('
', $modifiedFiles);

var_dump();

Output:

array(1) {
  [0]=>
  string(82) "app/Http/Controllers/SomeFile.php
app/Http/Controllers/OtherFile.php
"
}

I just want the output to be a PHP array of files. Any tips?

You have a couple of problems here:

explode('/n', $modifiedFiles);

This line needs to be

explode("
", $modifiedFiles);

Only double-quoted strings will interpret newlines and similar escape sequences, etc. See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double

You also have a forward-slash instead of a back-slash.