我不明白这段代码在 PHP 中做什么


I do not understand what this code is doing in PHP

我有这个代码,

// TEMP VAR
$temp = &$files;
// BUILD ARRAY STRUCTURE
while(count($file['path'])) {
    // GET DIRECTORY
    $directory = array_shift($file['path']);
    // DIRECTORY NOT SET
    if(!isset($temp[$directory])) {
        // SET DIRECTORY
        $temp[$directory] = array();
    }
    // GO INTO ARRAYS NEXT DIRECTORY
    $temp = &$temp[$directory];
}

我从这个问题的答案中得到了它,

具有数组结构到数组的字符串

我知道它做什么,但不知道它是如何做的,谁能逐行向我解释发生了什么?

谢谢大家。

此用法中的 & 符号是参考。请参阅此文章

$variable = 'Lorem ipsum';
$new = &$variable;
$variable = 'Some new data';
echo $new; //Prints "Some new data"