2
我有一個JSON解碼數組,如下所示,它具有到根的路徑。在數組中添加一個數組到一個數組中的多個根
$file_path = json_decode($_REQUEST['file_path']);
正如我們所知,我們可以添加多個根,如下所示。
$opts = array(
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => 'path/to/files/first_root', // path to files (REQUIRED)
'URL' => 'http://localhost/files/first_root/', // URL to files (REQUIRED)
'alias' => 'First home', // The name to replace your actual path name. (OPTIONAL)
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
),
array(
'driver' => 'LocalFileSystem',
'path' => 'path/to/files/second_root',
'URL' => 'http://localhost/files/second_root/',
'alias' => 'Second home'
)
)
);
我想動態地添加我的數組路徑,如下所示。
foreach ($file_path as $path){
$array_1[] = array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => $path, // path to files (REQUIRED)
'URL' => $path, // URL to files (REQUIRED)
'trashHash' => 't1_Lw', // elFinder's hash of trash folder
'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
'uploadDeny' => array('all', '*'), // All Mimetypes not allowed to upload
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
);
}
但問題是,這將增加額外的鍵對每個對象的前面。如下。
array(0 =>
array(
'driver' => 'LocalFileSystem',
'path' => 'path/to/files/first_root',
'URL' => 'http://localhost/files/first_root/',
'alias' => 'First home',
'accessControl' => 'access'
),
1 =>
array(
'driver' => 'LocalFileSystem',
'path' => 'path/to/files/second_root',
'URL' => 'http://localhost/files/second_root/',
'alias' => 'Second home'
));
如何刪除額外的數組鍵或在elFinder中完成此任務的方式。
你的意思是刪除0和1,這是數組索引,無法刪除它。 –
我們不能把它看作簡單的數組,像數組(「test」,「tes」,「te」)嗎? –
您可以像這樣分配值,但是當您需要訪問這些項目時,您需要鍵/索引 –